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

    <parent>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-integration-tests-spring</artifactId>
        <version>4.7.3.Final</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>resteasy-integration-tests-spring-deployment</artifactId>
    <name>RESTEasy Main testsuite: Spring integration tests - Deployment</name>

    <profiles>
        <!--
        Name:  download
        Descr: Download WildFly
        -->
        <profile>
          <id>download</id>
          <activation>
            <property>
              <name>!server.home</name>
            </property>
          </activation>
          <build>
            <plugins>
              <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.wildfly</groupId>
                                    <artifactId>wildfly-dist</artifactId>
                                    <version>${server.version}</version>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/test-server</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-resteasy</id>
                        <phase>generate-test-resources</phase>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <target>
                                <!-- Explicitly remove resteasy-spring contents as the module.xml does not reference resource jars in this case
                                     so adding jars without removing old ones basically messes up the classloader -->
                                <delete>
                                    <fileset dir="${project.build.directory}/test-server/wildfly-${server.version}/modules/system/layers/base/org/jboss/resteasy/resteasy-spring/main" includes="**/*.jar"/>
                                </delete>
                                <unzip src="../../../jboss-modules/target/resteasy-jboss-modules-${project.version}.zip"
                                       dest="${project.build.directory}/test-server/wildfly-${server.version}/modules/system/layers/base"
                                       overwrite="true"/>
                                <delete dir="target/dependency-maven-plugin-markers"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
              </plugin>
            </plugins>
          </build>
          <properties>
            <jboss.home>${project.build.directory}/test-server/wildfly-${server.version}</jboss.home>
          </properties>
        </profile>
    </profiles>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>arquillian.xml</include>
                </includes>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
                <excludes>
                    <exclude>arquillian.xml</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <version.org.springframework>${version.org.springframework}</version.org.springframework>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enable-elytron-full-cli</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>execute-commands</goal>
                        </goals>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <jboss-home>${jboss.home}</jboss-home>
                            <offline>true</offline>
                            <scripts>
                                <script>${basedir}/../../config/enable-elytron-full.cli</script>
                            </scripts>
                            <stdout>${project.build.directory}/elytron-config.out</stdout>
                            <system-properties>
                                <jboss.server.config.file.name>${jboss.server.config.file.name}</jboss.server.config.file.name>
                            </system-properties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
