<?xml version='1.0' encoding='UTF-8'?>
<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.infinispan</groupId>
        <artifactId>infinispan-server-integration</artifactId>
        <version>12.0.0.Dev3</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>infinispan-third-party-integrationtests</artifactId>

    <properties>
        <version.wildfly>${appserver.version}</version.wildfly>
        <version.arquillian-tomcat-managed>1.1.0.Final</version.arquillian-tomcat-managed>
        <ispnserver.project.dir>${basedir}/../../../server/runtime</ispnserver.project.dir>
        <ispn.config.file>${basedir}/../server-integration-commons/src/test/resources/infinispan-custom.xml</ispn.config.file>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.infinispan.protostream</groupId>
            <artifactId>protostream-processor</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-commons-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-client-hotrod</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-server-integrationtests-commons</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-depchain</artifactId>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.descriptors</groupId>
            <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <arquillian.launch>${infinispan.server.integration.launch}</arquillian.launch>
                        <catalinaHome>${catalinaHome}</catalinaHome>
                        <jbossHome>${jbossHome}</jbossHome>
                        <server.jvm>${server.jvm}</server.jvm>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>smoke</id>
            <properties>
                <skipTests>true</skipTests>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <skipITs>${skipTests}</skipITs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>third-party-tomcat</id>
            <activation>
                <property>
                    <name>infinispan.server.integration.launch</name>
                    <value>tomcat</value>
                </property>
            </activation>
            <properties>
                <infinispan.server.integration.launch>tomcat</infinispan.server.integration.launch>
                <catalinaHome>${project.build.directory}/tomcat</catalinaHome>
            </properties>
            <dependencies>
                <!-- there is no arquillian-tomcat-managed-9. we are using arquillian-tomcat-managed-8 -->
                <dependency>
                    <groupId>org.jboss.arquillian.container</groupId>
                    <artifactId>arquillian-tomcat-managed-8</artifactId>
                    <version>${version.arquillian-tomcat-managed}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <target>
                                        <echo message="unzipping tomcat server" />
                                        <unzip src="${tomcat.zip}" dest="${project.build.directory}/tomcat" />
                                        <pathconvert property="tomcat.unzip.dir">
                                            <dirset dir="${project.build.directory}/tomcat" includes="apache-tomcat-*"/>
                                        </pathconvert>
                                        <move todir="${project.build.directory}/tomcat">
                                            <fileset dir="${tomcat.unzip.dir}"/>
                                        </move>
                                        <copy file="${basedir}/src/test/resources/tomcat/tomcat-users.xml" todir="${project.build.directory}/tomcat/conf" overwrite="true" />
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>third-party-wildfly</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>infinispan.server.integration.launch</name>
                    <value>wildfly</value>
                </property>
            </activation>
            <properties>
                <infinispan.server.integration.launch>wildfly</infinispan.server.integration.launch>
                <jbossHome>${project.build.directory}/wildfly-${version.wildfly}</jbossHome>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly.arquillian</groupId>
                    <artifactId>wildfly-arquillian-container-managed</artifactId>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipTests}</skip>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wildfly</groupId>
                                            <artifactId>wildfly-dist</artifactId>
                                            <version>${version.wildfly}</version>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
