<?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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>hercules-ac-integration-tests</artifactId>

    <parent>
        <groupId>com.atlassian.addon.connect.hercules</groupId>
        <artifactId>hercules-ac-parent</artifactId>
        <version>1.1.2</version>
    </parent>

    <name>Hercules Atlassian Connect Integration Tests</name>

    <packaging>atlassian-plugin</packaging>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.addon.connect.hercules</groupId>
            <artifactId>hercules-ac</artifactId>
            <version>${project.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.jira.tests</groupId>
            <artifactId>jira-testkit-client</artifactId>
            <version>${testkit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>atlassian-jira-pageobjects</artifactId>
            <version>${jira.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>sfl4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-webdriver-tests</artifactId>
            <version>${jira.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira.tests</groupId>
            <artifactId>jira-func-test-basics</artifactId>
            <version>${func-test-basic}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <!-- This is needed for surefire plugin to exclude IT tests from running them as unit tests -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/*$*</exclude>
                        <exclude>it/**</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-amps-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <systemPropertyVariables>
                        <xvfb.enable>${xvfb.enable}</xvfb.enable>
                        <atlassian.test.target.dir>${project.build.directory}</atlassian.test.target.dir>
                    </systemPropertyVariables>
                    <jvmArgs>-XX:MaxPermSize=512m -Xmx1024m -Datlassian.mail.senddisabled=false</jvmArgs>
                    <products>
                        <product>
                            <id>jira</id>
                            <instanceId>jira</instanceId>

                            <jvmDebugPort>5005</jvmDebugPort>
                            <httpPort>2990</httpPort>

                            <version>${jira.version}</version>
                            <productDataVersion>${jira.version}</productDataVersion>
                            <productDataPath>${basedir}/src/test/xml/jira-generated-test-resources.zip</productDataPath>

                            <pluginArtifacts>
                                <pluginArtifact>
                                    <groupId>com.atlassian.jira.tests</groupId>
                                    <artifactId>jira-testkit-plugin</artifactId>
                                    <version>${testkit.version}</version>
                                </pluginArtifact>

                                <pluginArtifact>
                                    <groupId>com.atlassian.plugins</groupId>
                                    <artifactId>atlassian-connect-plugin</artifactId>
                                    <version>${ac.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.jwt</groupId>
                                    <artifactId>jwt-plugin</artifactId>
                                    <version>${jwt.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.bundles</groupId>
                                    <artifactId>json-schema-validator-atlassian-bundle</artifactId>
                                    <version>${schemavalidator.version}</version>
                                </pluginArtifact>
                            </pluginArtifacts>
                        </product>
                    </products>
                    <testGroups>
                        <testGroup>
                            <id>jira-integration</id>
                            <productIds>
                                <productId>jira</productId>
                            </productIds>
                            <includes>
                                <include>it/**/Test*.java</include>
                            </includes>
                        </testGroup>
                    </testGroups>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>start-play-app</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <target>
                                <exec executable="${basedir}/run-play.sh" spawn="true">
                                    <env key="JAVA_HOME" value="${env.JAVA_HOME}" />
                                    <env key="MVN_HOME" value="${env.M2_HOME}" />
                                    <env key="M2_HOME" value="${env.M2_HOME}" />
                                    <env key="MAVEN2_HOME" value="${env.MAVEN2_HOME}" />
                                    <env key="PLAY2_HOME" value="${env.PLAY2_HOME}" />
                                    <env key="MAVEN_OPTS" value="${env.MAVEN_OPTS}" />
                                    <env key="PATH" value="${env.PATH}" />
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <properties>
        <plugin.testrunner.version>1.1.1</plugin.testrunner.version>
        <!-- TestKit version 5.x for JIRA 5.x, 6.x for JIRA 6.x -->
        <testkit.version>6.0.45</testkit.version>
        <func-test-basic>1.9.5</func-test-basic>

        <jira.version>6.2.1</jira.version>
        <ac.version>1.0.2</ac.version>
        <jwt.version>1.0.0</jwt.version>
        <schemavalidator.version>1.0-m0</schemavalidator.version>
        <xvfb.enable>true</xvfb.enable>
    </properties>

</project>
