<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <packaging>jar</packaging>

    <artifactId>dbus-java-tests</artifactId>

    <name>${project.artifactId}</name>

    <description>
        dbus-java test module.
    </description>

    <parent>
        <groupId>com.github.hypfvieh</groupId>
        <artifactId>dbus-java-parent</artifactId>
        <version>4.3.1</version>
    </parent>

    <properties>
        <!-- Disable native transport tests by default (will be enabled by profile if JDK 16+ is present) -->
        <jdk16.not.found>true</jdk16.not.found>
        <parentDir>${project.parent.basedir}</parentDir>
    </properties>

    <build>
        <plugins>
            <plugin>
				<!--
					For debugging with maven:
					mvn clean test-compile surefire:test@native-tests -Dtest=TestAll -Dmaven.surefire.debug 
				-->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <id>native-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skip>${jdk16.not.found}</skip> <!-- skip if not JDK 16+ -->
                            <skipAfterFailureCount>1</skipAfterFailureCount>
                            <classpathDependencyExcludes>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-tcp</classpathDependencyExclude>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-jnr-unixsocket</classpathDependencyExclude>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-junixsocket</classpathDependencyExclude>
                            </classpathDependencyExcludes>
                        </configuration>
                    </execution>
                    <execution> <!-- no tests without transport -->
                        <id>default-test</id>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>jnr-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipAfterFailureCount>1</skipAfterFailureCount>
                            <classpathDependencyExcludes>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-tcp</classpathDependencyExclude>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-native-unixsocket</classpathDependencyExclude>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-junixsocket</classpathDependencyExclude>
                            </classpathDependencyExcludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>junixsocket-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipAfterFailureCount>1</skipAfterFailureCount>
                            <classpathDependencyExcludes>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-tcp</classpathDependencyExclude>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-jnr-unixsocket</classpathDependencyExclude>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-native-unixsocket</classpathDependencyExclude>
                            </classpathDependencyExcludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>tcp-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipAfterFailureCount>1</skipAfterFailureCount>
                            <classpathDependencyExcludes>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-native-unixsocket</classpathDependencyExclude>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-jnr-unixsocket</classpathDependencyExclude>
                                <classpathDependencyExclude>${project.groupId}:dbus-java-transport-junixsocket</classpathDependencyExclude>
                            </classpathDependencyExcludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.github.hypfvieh</groupId>
            <artifactId>dbus-java-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.github.hypfvieh</groupId>
            <artifactId>dbus-java-transport-tcp</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.github.hypfvieh</groupId>
            <artifactId>dbus-java-transport-jnr-unixsocket</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.github.hypfvieh</groupId>
            <artifactId>dbus-java-transport-junixsocket</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>jdk-16-available</id>
            <activation>
                <jdk>[16,)</jdk> <!-- requires JDK 16 or higher -->
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>compile</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>16</release>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>

            <dependencies>
                <dependency>
                    <groupId>com.github.hypfvieh</groupId>
                    <artifactId>dbus-java-transport-native-unixsocket</artifactId>
                    <version>${project.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>

            <properties>
                <!-- Setting this to false will enable native-transport tests -->
                <jdk16.not.found>false</jdk16.not.found>
            </properties>
        </profile>
    </profiles>
    
</project>
