<?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.jira</groupId>
        <artifactId>jira-rest-java-client-parent</artifactId>
        <version>5.2.8-platform7-b3fe2741</version>
    </parent>

    <artifactId>jira-rest-java-client-test</artifactId>

    <name>JIRA REST Java Client - Tests</name>
    <description>Tests of JIRA REST Java Client.</description>

    <properties>
        <plugins>com.atlassian.jira.tests:jira-testkit-plugin:${testkit.version}</plugins>
        <jira.jvm.args>-Xms512m -Xmx1024m</jira.jvm.args>
        <enforcer.skip>true</enforcer.skip>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.atlassian.fugue</groupId>
            <artifactId>fugue</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jettison</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.jettison</groupId>
                    <artifactId>jettison</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jettison</groupId>
            <artifactId>jettison</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-func-tests</artifactId>
            <version>${jira.test-lib.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.sun.jersey</groupId>
                    <artifactId>jersey-server</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.collections</groupId>
                    <artifactId>google-collections</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j2-impl</artifactId>
            <version>2.20.0</version>
        </dependency>
    </dependencies>

    <build>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>src/test/xml</directory>
            </testResource>
        </testResources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.twdata.maven</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <version>1.0-beta-2-db2</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>jira-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${jira.version}</productVersion>
                    <productDataVersion>${jira.data.version}</productDataVersion>
                    <containerId>tomcat9x</containerId>
                    <jvmArgs>${jira.jvm.args}</jvmArgs>
                    <enableFastdev>false</enableFastdev>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.5</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                    <excludes>
                        <exclude>it/**</exclude>
                        <exclude>it2/**</exclude>
                    </excludes>
                    <forkMode>once</forkMode>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <preparationGoals>clean test</preparationGoals>
                    <releaseProfiles>releaseProfile</releaseProfiles>
                    <!--allowTimestampedSnapshots>true</allowTimestampedSnapshots-->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>1.3.1</version>
                <configuration>
                    <properties>
                        <property>
                            <name>jira.version</name>
                            <dependencies>
                                <dependency>
                                    <groupId>com.atlassian.jira</groupId>
                                    <artifactId>jira-core</artifactId>
                                </dependency>
                            </dependencies>
                        </property>
                    </properties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.4</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jira-post-7.2</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>jira-cloud</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <jira.version>1001.0.0-QR20160727011801</jira.version>
                <amps.version>8.12.4</amps.version>
                <testkit.version>1000.1.7</testkit.version>
                <postgres.docker.image>docker.atl-paas.net/jira-cloud/postgres-ci:9.5</postgres.docker.image>
                <postgres.docker.wait.log.regex>database system is ready to accept connections</postgres.docker.wait.log.regex>
                <postgres.docker.wait.timeout>600000</postgres.docker.wait.timeout>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>9.4.1208</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>jira-maven-plugin</artifactId>
                        <version>${amps.version}</version>
                        <configuration>
                            <libArtifacts>
                                <libArtifact>
                                    <groupId>org.postgresql</groupId>
                                    <artifactId>postgresql</artifactId>
                                    <version>9.4.1208</version>
                                </libArtifact>
                            </libArtifacts>

                            <systemPropertyVariables>
                                <PG_DB_ROLE>jira</PG_DB_ROLE>
                                <PG_DB_HOST>${docker.host.address}</PG_DB_HOST>
                                <PG_DB_NAME>jira</PG_DB_NAME>
                                <PG_DB_PASSWORD>jira</PG_DB_PASSWORD>
                                <PG_DB_PORT>${database.port}</PG_DB_PORT>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>0.14.2</version>
                        <configuration>
                            <autoPull>always</autoPull>
                            <images>
                                <image>
                                    <alias>postgres-db</alias>
                                    <name>${postgres.docker.image}</name>
                                    <run>
                                        <ports>
                                            <port>database.port:5432</port>
                                        </ports>
                                        <wait>
                                            <log>${postgres.docker.wait.log.regex}</log>
                                            <time>${postgres.docker.wait.timeout}</time>
                                        </wait>
                                        <log>
                                            <prefix>postgres</prefix>
                                            <date>default</date>
                                            <color>cyan</color>
                                        </log>
                                    </run>
                                </image>
                            </images>
                        </configuration>

                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>releaseProfile</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
            </properties>
        </profile>
        <profile>
            <id>jacoco</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <propertyName>jacoco.agent</propertyName>
                                    <includes>
                                        <include>com/atlassian/**</include>
                                    </includes>
                                </configuration>
                            </execution>
                            <execution>
                                <id>report</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>maven-jira-plugin</artifactId>
                        <configuration>
                            <jvmArgs>${jira.jvm.args} ${jacoco.agent}</jvmArgs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
