<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">
    <parent>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs-all</artifactId>
        <version>5.0.0.Beta3</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <name>RESTEasy Main testsuite</name>
    <description/>
    <modelVersion>4.0.0</modelVersion>
    <packaging>pom</packaging>

    <artifactId>resteasy-testsuite</artifactId>

    <properties>
        <version.resteasy.testsuite>${project.version}</version.resteasy.testsuite>
        <additional.surefire.excluded.groups/>
        <!-- default value required for cmd-line -->
        <securityManagerArg>-DSECMGR="false"</securityManagerArg>
        <jacoco.agent/>
        <additionalJvmArgs/>
        <ipv6ArquillianSettings/>
        <debugJvmArgs/>
        <jboss.server.config.file.name>standalone-full.xml</jboss.server.config.file.name>
        <server.version>${version.org.wildfly}</server.version>

        <!-- Skip the default Java 8 testing. This will have to be done in CI or locally by setting the test.java.home -->
        <skip.java8.tests>true</skip.java8.tests>
        <test.java.home>${java.home}</test.java.home>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>${dep.arquillian-bom.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-weld-embedded</artifactId>
                <version>${version.org.jboss.arquillian.container.arquillian-weld-embedded}</version>
            </dependency>
            <!-- Placed here to be resolved for other sub-modules -->
            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>arquillian-utils</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.wildfly.arquillian</groupId>
                <artifactId>wildfly-arquillian-container-managed</artifactId>
                <version>${version.org.wildfly.arquillian.wildfly-arquillian}</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.inject</groupId>
                        <artifactId>javax.inject</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.wildfly.arquillian</groupId>
                <artifactId>wildfly-arquillian-container-bootable</artifactId>
                <version>${version.org.wildfly.arquillian.wildfly-arquillian}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.jboss.sasl</groupId>
                        <artifactId>jboss-sasl</artifactId>
                    </exclusion>
                    <!-- TODO remove this exclusion once this depends on Jakarta Inject -->
                    <!-- superseded by jakarta.inject:jakarta.inject-api -->
                    <exclusion>
                        <groupId>javax.inject</groupId>
                        <artifactId>javax.inject</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <!-- rls test
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-help-plugin</artifactId>
                    <version>3.2.0</version>
            </plugin>
-->
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-help-plugin</artifactId>
                    <version>3.2.0</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <jvm>${test.java.home}/bin/java</jvm>
                    <failIfNoTests>false</failIfNoTests>
                    <systemPropertyVariables>
                        <securityManagerArg>${securityManagerArg}</securityManagerArg>
                        <additionalJvmArgs>${additionalJvmArgs}</additionalJvmArgs>
                        <ipv6>false</ipv6>
                        <ipv6ArquillianSettings></ipv6ArquillianSettings>
                        <node>127.0.0.1</node>
                        <jboss.home>${jboss.home}</jboss.home>
                        <project.version>${project.version}</project.version>
                        <version.resteasy.testsuite>${version.resteasy.testsuite}</version.resteasy.testsuite>
                        <jboss.server.config.file.name>${jboss.server.config.file.name}</jboss.server.config.file.name>
                    </systemPropertyVariables>
                    <excludedGroups>org.jboss.resteasy.category.ExpectedFailing${additional.surefire.excluded.groups}</excludedGroups>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${version.enforcer.plugin}</version>
                <executions>
                    <execution>
                        <id>dep-convergence</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <property>
                    <name>!skipDefaultProfile</name>
                </property>
            </activation>
            <modules>
                <module>arquillian-utils</module>
                <module>unit-tests</module>
                <module>integration-tests</module>
                <module>integration-tests-embedded</module>
            </modules>
        </profile>
        <profile>
            <id>home</id>
            <activation>
                <property>
                  <name>!jboss.home</name>
                </property>
            </activation>
            <properties>
                <jboss.home>${server.home}</jboss.home>
            </properties>
        </profile>
        <profile>
            <id>server-version-21x-exclusions</id>
            <activation>
                <property>
                    <name>server.version</name>
                    <value>21.0.1.Final</value>
                </property>
            </activation>
            <properties>
                <additional.surefire.excluded.groups>,org.jboss.resteasy.category.ExpectedFailingOnWildFly21</additional.surefire.excluded.groups>
            </properties>
        </profile>
        <profile>
            <id>server-version-20x-exclusions</id>
            <activation>
                <property>
                    <name>server.version</name>
                    <value>20.0.1.Final</value>
                </property>
            </activation>
            <properties>
                <additional.surefire.excluded.groups>,org.jboss.resteasy.category.ExpectedFailingOnWildFly20</additional.surefire.excluded.groups>
            </properties>
        </profile>
        <profile>
            <id>server-version-19x-exclusions</id>
            <activation>
                <property>
                    <name>server.version</name>
                    <value>19.1.0.Final</value>
                </property>
            </activation>
            <properties>
                <additional.surefire.excluded.groups>,org.jboss.resteasy.category.ExpectedFailingOnWildFly19</additional.surefire.excluded.groups>
            </properties>
        </profile>
        <profile>
            <id>server-version-18x-exclusions</id>
            <activation>
                <property>
                    <name>server.version</name>
                    <value>18.0.1.Final</value>
                </property>
            </activation>
            <properties>
                <additional.surefire.excluded.groups>,org.jboss.resteasy.category.ExpectedFailingOnWildFly18</additional.surefire.excluded.groups>
            </properties>
        </profile>
        <!-- If resteasy.version is specified, it will be used for tests instead of the project.version -->
        <profile>
            <id>custom-resteasy-version</id>
            <activation>
                <property>
                    <name>version.resteasy.testsuite</name>
                </property>
            </activation>
            <properties>
                <version.resteasy.testsuite>${version.resteasy.testsuite}</version.resteasy.testsuite>
            </properties>
        </profile>

        <profile>
            <id>java8-integration-tests</id>
            <activation>
                <property>
                    <name>test.java8.home</name>
                </property>
            </activation>
            <properties>
                <test.java.home>${test.java8.home}</test.java.home>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <additionalClasspathElements>
                                <additionalClasspathElement>${test.java.home}/lib/tools.jar</additionalClasspathElement>
                            </additionalClasspathElements>
                            <environmentVariables>
                                <JAVA_HOME>${test.java.home}</JAVA_HOME>
                            </environmentVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>ipv6</id>
            <activation>
                <property>
                    <name>ipv6</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <testFailureIgnore>true</testFailureIgnore>
                            <systemPropertyVariables>
                                <securityManagerArg>${securityManagerArg}</securityManagerArg>
                                <additionalJvmArgs>${additionalJvmArgs}</additionalJvmArgs>
                                <ipv6>true</ipv6>
                                <ipv6ArquillianSettings>-Djava.net.preferIPv4Stack=false -Djava.net.preferIPv6Addresses=true</ipv6ArquillianSettings>
                                <node>::1</node>
                                <project.version>${project.version}</project.version>
                                <version.resteasy.testsuite>${version.resteasy.testsuite}</version.resteasy.testsuite>
                            </systemPropertyVariables>
                            <excludedGroups>org.jboss.resteasy.category.ExpectedFailing</excludedGroups>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
        <!-- For testing purposes enable to run all tests including the failing ones -->
        <profile>
            <id>enable.expected.failing</id>
            <activation>
                <property>
                    <name>enable.expected.failing</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration combine.children="append">
                            <excludedGroups></excludedGroups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- This profile starts server with security manager -->
        <profile>
            <id>security.manager</id>
            <activation>
                <property>
                    <name>security.manager</name>
                </property>
            </activation>
            <properties>
                <securityManagerArg>-secmgr</securityManagerArg>
            </properties>
        </profile>
        <!-- This profile generates jacoco coverage files. To generate html report use "-Djacoco.generate.report" -->
        <profile>
            <id>jacoco</id>
            <activation>
                <property>
                    <name>jacoco</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jacoco</groupId>
                    <artifactId>org.jacoco.core</artifactId>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                     <plugin>
                         <groupId>org.jacoco</groupId>
                         <artifactId>jacoco-maven-plugin</artifactId>
                         <executions>
                             <execution>
                                 <id>jacoco-prepare</id>
                                 <phase>validate</phase>
                                 <goals>
                                     <goal>prepare-agent</goal>
                                 </goals>
                                 <configuration>
                                     <destFile>${project.build.directory}/jacoco.exec</destFile>
                                     <!-- Jacoco sets this property with agent configuration.
                                     This property is passed to maven-surefire-plugin -->
                                     <propertyName>surefireArgLine</propertyName>
                                 </configuration>
                             </execution>
                             <execution>
                                 <id>jacoco-prepare-it</id>
                                 <phase>validate</phase>
                                 <goals>
                                     <goal>prepare-agent-integration</goal>
                                 </goals>
                                 <configuration>
                                     <destFile>${project.build.directory}/jacoco.exec</destFile>
                                     <!-- Jacoco sets this property with agent configuration.
                                     This property is passed to maven-surefire-plugin as system property variable jacoco.agent.
                                     jacoco.agent property is passed to arquillian.xml -->
                                     <propertyName>jacoco.agent</propertyName>
                                 </configuration>
                             </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>${surefireArgLine}</argLine>
                            <skipTests>false</skipTests>
                            <systemPropertyVariables>
                                <jacoco.agent>@{jacoco.agent}</jacoco.agent>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- This profile generates html report from jacoco coverage files. Use "-Djacoco" property to generate coverage. -->
        <profile>
            <id>jacoco-generate-report</id>
            <activation>
                <property>
                    <name>jacoco.generate.report</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <!-- Copy jacoco ant jar. This is needed to generate jacoco report with maven-antrun-plugin -->
                            <execution>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <phase>process-test-resources</phase>
                                <inherited>false</inherited>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.jacoco</groupId>
                                            <artifactId>org.jacoco.ant</artifactId>
                                            <version>${version.org.jacoco.plugin}</version></artifactItem>
                                    </artifactItems>
                                    <stripVersion>true</stripVersion>
                                    <outputDirectory>${project.build.directory}/jacoco-jars</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>post-integration-test</phase>
                                <goals><goal>run</goal></goals>
                                <inherited>false</inherited>
                                <configuration>
                                    <skip>${skipTests}</skip>
                                    <target>
                                        <property name="result.report.dir" location="target/jacoco-report"/>
                                        <taskdef name="report" classname="org.jacoco.ant.ReportTask">
                                            <classpath path="${project.build.directory}/jacoco-jars/org.jacoco.ant.jar"/>
                                        </taskdef>
                                        <echo>Creating JaCoCo RESTEasy test coverage reports...</echo>
                                        <report>
                                            <executiondata>
                                                <fileset dir="${basedir}">
                                                    <include name="**/target/jacoco.exec"/>
                                                </fileset>
                                            </executiondata>
                                            <structure name="JaCoCo RESTEasy">
                                                <classfiles>
                                                    <fileset dir="${basedir}/integration-tests/target/test-server">
                                                        <include name="**/resteasy*${project.version}.jar"/>
                                                        <include name="**/jose-jwt*${project.version}.jar"/>
                                                        <include name="**/async-http-servlet*.jar"/>
                                                        <include name="**/jboss-jaxrs-api*.jar"/>
                                                        <include name="**/jackson-jaxrs*.jar"/>
                                                        <include name="**/jackson-module*.jar"/>
                                                        <include name="**/wildfly-jaxrs*.jar"/>
                                                    </fileset>
                                                </classfiles>
                                                <sourcefiles encoding="UTF-8">
                                                    <dirset dir="${basedir}/..">
                                                        <include name="**/src/main/java"/>
                                                    </dirset>
                                                </sourcefiles>
                                            </structure>
                                            <html destdir="\${result.report.dir}"/>
                                            <xml destfile="\${result.report.dir}/report.xml"/>
                                        </report>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.jacoco</groupId>
                                <artifactId>org.jacoco.ant</artifactId>
                                <version>${version.org.jacoco.plugin}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>debug</id>
            <activation>
                <property>
                    <name>debug</name>
                </property>
            </activation>
            <properties>
                <debug.port>8787</debug.port>
                <debugJvmArgs>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:${debug.port}</debugJvmArgs>
            </properties>
        </profile>

        <profile>
            <id>debug-java-8</id>
            <activation>
                <property>
                    <name>debug.java.8</name>
                </property>
            </activation>
            <properties>
                <debug.port>8787</debug.port>
                <debugJvmArgs>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${debug.port}</debugJvmArgs>
            </properties>
        </profile>
    </profiles>

</project>

