<?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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.atlassian.mywork</groupId>
        <artifactId>mywork-project</artifactId>
        <version>8.1.10</version>
    </parent>

    <artifactId>mywork-acceptance-test-runner</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Workbox - Acceptance Test Runner</name>
    <description>Runs Acceptance Tests for Workbox</description>

    <properties>
        <instanceId>confluence-host</instanceId>
        <skip.smoke.test>true</skip.smoke.test>
        <root.dir>..</root.dir>
        <testGroups>fast</testGroups>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.confluence</groupId>
                <artifactId>confluence-plugins-platform-test-pom</artifactId>
                <version>${confluence.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>26.0-jre</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.mywork</groupId>
            <artifactId>mywork-acceptance-tests</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- We need guice 4.0 in tests (uses proper asm) for support of java 8 -->
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>${guice.test.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.mywork</groupId>
            <artifactId>mywork-confluence-host-plugin</artifactId>
            <version>${project.version}</version>
            <type>atlassian-plugin</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.mywork</groupId>
            <artifactId>mywork-confluence-provider-plugin</artifactId>
            <version>${project.version}</version>
            <type>atlassian-plugin</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.mywork</groupId>
            <artifactId>mywork-jira-provider-plugin</artifactId>
            <version>${project.version}</version>
            <type>atlassian-plugin</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.mywork</groupId>
            <artifactId>mywork-common-plugin</artifactId>
            <version>${project.version}</version>
            <type>atlassian-plugin</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-rest-client</artifactId>
            <version>${confluence.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-acceptance-tests</artifactId>
                                    <version>${project.version}</version>
                                    <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>amps-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <systemPropertyVariables>
                        <xvfb.enable>${xvfb.enable}</xvfb.enable>
                        <os.arch.override>${os.arch.override}</os.arch.override>
                        <!-- I'm not aware of better way to say that we have no resource directory -->
                        <plugin.resource.directories>,</plugin.resource.directories>
                        <confluence.version>${confluence.version}</confluence.version>
                        <webdriver.browser>${webdriver.browser}</webdriver.browser>
                    </systemPropertyVariables>

                    <products>
                        <product>
                            <id>jira</id>
                            <jvmArgs>${jira.jvm.args}</jvmArgs>
                            <containerId>${jira.container}</containerId>
                            <instanceId>jira-client</instanceId>
                            <version>${jira.version}</version>
                            <dataPath>${project.build.testOutputDirectory}/amps/jira-test-resources.zip</dataPath>
                            <httpPort>2991</httpPort>
                            <ajpPort>8010</ajpPort>
                            <contextPath>/jira-client</contextPath>
                            <log4jProperties>${project.build.testOutputDirectory}/amps/jira-log4j.properties</log4jProperties>
                            <output>${project.build.directory}/jira-client/target/output.log</output>
                            <installPlugin>false</installPlugin>
                            <systemPropertyVariables>
                                <cargo.java.home>${jira.java.home}</cargo.java.home>
                            </systemPropertyVariables>
                            <pluginArtifacts>
                                <pluginArtifact>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-common-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-jira-provider-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                            </pluginArtifacts>
                        </product>
                        <product>
                            <id>confluence</id>
                            <jvmArgs>${jvm.args}</jvmArgs>
                            <containerId>${container}</containerId>
                            <instanceId>confluence-host</instanceId>
                            <server>localhost</server>
                            <version>${confluence.version}</version>
                            <dataVersion>${confluence.data.version}</dataVersion>
                            <ajpPort>8009</ajpPort>
                            <output>${project.build.directory}/confluence-host/target/output.log</output>
                            <installPlugin>false</installPlugin>
                            <systemPropertyVariables>
                                <cargo.java.home>${confluence.java.home}</cargo.java.home>
                            </systemPropertyVariables>
                            <pluginArtifacts>
                                <pluginArtifact>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-confluence-host-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-common-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-confluence-provider-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                            </pluginArtifacts>
                        </product>
                        <product>
                            <id>confluence</id>
                            <jvmArgs>${jvm.args}</jvmArgs>
                            <containerId>${container}</containerId>
                            <instanceId>confluence-client</instanceId>
                            <version>${confluence.version}</version>
                            <!-- use custom data in confluence-client -->
                            <dataPath>${project.build.testOutputDirectory}/amps/confluence</dataPath>
                            <httpPort>1991</httpPort>
                            <contextPath>/confluence-client</contextPath>
                            <output>${project.build.directory}/confluence-client/target/output.log</output>
                            <installPlugin>false</installPlugin>
                            <pluginArtifacts>
                                <pluginArtifact>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-confluence-host-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-common-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.mywork</groupId>
                                    <artifactId>mywork-confluence-provider-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                            </pluginArtifacts>
                        </product>
                    </products>
                    <wait>true</wait>
                    <parallel>true</parallel>
                    <testGroups>
                        <testGroup>
                            <id>all</id>
                            <productIds>
                                <productId>confluence-host</productId>
                                <productId>confluence-client</productId>
                                <productId>jira-client</productId>
                            </productIds>
                            <includes>
                                <include>it/**/*Test.java</include>
                            </includes>
                        </testGroup>
                        <testGroup>
                            <id>fast</id>
                            <productIds>
                                <productId>confluence-host</productId>
                                <productId>jira-client</productId>
                            </productIds>
                            <includes>
                                <include>it/**/*Test.java</include>
                            </includes>
                        </testGroup>
                    </testGroups>
                </configuration>
            </plugin>
            <plugin><!-- JIRA's bundled plugins test framework requires test-jar -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                        <configuration>
                            <forceCreation>true</forceCreation>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>ban_junit5</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <rules>
                                <bannedDependencies>
                                    <searchTransitive>true</searchTransitive>
                                    <message>JUnit5 dependencies will break failsafe test discovery</message>
                                    <excludes>
                                        <exclude>org.junit.platform:*</exclude>
                                        <exclude>org.junit.jupiter:*</exclude>
                                    </excludes>
                                </bannedDependencies>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>skipTests</id>
            <properties>
                <skipTests>true</skipTests>
            </properties>
        </profile>
    </profiles>
</project>
