<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>prospero</artifactId>
        <groupId>org.wildfly.prospero</groupId>
        <version>1.3.10.Final-redhat-00002</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>prospero-integration-tests</artifactId>
    <name>Prospero Integration tests</name>

    <properties>
        <maven.deploy.skip>true</maven.deploy.skip>
        <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>prospero-common</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>prospero-cli</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.galleon</groupId>
            <artifactId>galleon-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.xnio</groupId>
            <artifactId>xnio-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.xnio</groupId>
            <artifactId>xnio-nio</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>write-project-properties</goal>
                        </goals>
                        <configuration>
                            <outputFile>${project.build.outputDirectory}/properties-from-pom.properties</outputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>integration-tests</id>
            <activation>
                <property>
                    <name>allTests</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly.prospero</groupId>
                    <artifactId>prospero-wildfly-galleon-pack</artifactId>
                    <version>${project.version}</version>
                    <classifier>manifest</classifier>
                    <type>yaml</type>
                    <scope>test</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>*</groupId>
                            <artifactId>*</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <!-- we need the prospero distribution to be build for integration tests -->
                <dependency>
                    <groupId>org.wildfly.prospero</groupId>
                    <artifactId>prospero-build</artifactId>
                    <version>${project.version}</version>
                    <type>zip</type>
                    <scope>test</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>*</groupId>
                            <artifactId>*</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-prospero-channel</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wildfly.prospero</groupId>
                                            <artifactId>prospero-wildfly-galleon-pack</artifactId>
                                            <version>${project.version}</version>
                                            <classifier>manifest</classifier>
                                            <type>yaml</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test-classes/manifests</outputDirectory>
                                            <destFileName>prospero-manifest.yaml</destFileName>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-prospero-dist</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wildfly.prospero</groupId>
                                            <artifactId>prospero-build</artifactId>
                                            <version>${project.version}</version>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test-classes/prospero-dist</outputDirectory>
                                            <!-- use the file mapper to remove the top level folder -->
                                            <fileMappers>
                                                <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                                    <pattern>${prospero.dist.name}-[^/]*/</pattern>
                                                    <replacement>./</replacement>
                                                </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                            </fileMappers>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>false</skipTests>
                            <reuseForks>false</reuseForks> <!-- Don't reuse forks to avoid jboss-modules hanging on in the classpath -->
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>skip-container-tests</id>
            <activation>
                <property>
                    <name>skip.container.tests</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <exclude>org/wildfly/prospero/extended/**</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>single-test</id>
            <activation>
                <property>
                    <name>test</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>false</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
