<?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.linked-planet.client</groupId>
        <artifactId>kotlin-jira-client</artifactId>
        <version>0.9.2</version>
    </parent>

    <artifactId>kotlin-jira-client-test-sdk</artifactId>
    <name>kotlin-jira-client-test-sdk</name>
    <packaging>atlassian-plugin</packaging>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <atlassian.spring.scanner.version>2.2.1</atlassian.spring.scanner.version>

        <jira.http.port>2990</jira.http.port>
    </properties>

    <dependencies>
        <!-- kotlin-jira-client -->
        <dependency>
            <groupId>com.linked-planet.client</groupId>
            <artifactId>kotlin-jira-client-sdk</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.linked-planet.client</groupId>
            <artifactId>kotlin-jira-client-test-base</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- External -->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>jta</groupId>
                    <artifactId>jta</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>jta</groupId>
                    <artifactId>jta</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jndi</groupId>
                    <artifactId>jndi</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-plugin</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>jta</groupId>
                    <artifactId>jta</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.atlassian.jira.plugins</groupId>
            <artifactId>insight</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.ehcache</groupId>
                    <artifactId>ehcache</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.atlassian.translations</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.atlassian.jira.plugins</groupId>
                    <artifactId>insight-core-widget-report</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2-atlassian-1</version>
        </dependency>

        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <version>4.2.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jta</groupId>
            <artifactId>jta</artifactId>
            <version>1.0.1b</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker-qual</artifactId>
            <version>2.8.1</version>
        </dependency>

        <!-- WIRED TEST RUNNER DEPENDENCIES -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
            <version>2.0.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testSourceDirectory>src/test/kotlin</testSourceDirectory>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.0.0-M1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.21.0</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- INTEGRATION TEST only for ci-profile -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>it/**/*.java</include>
                    </includes>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>

            <!-- JIRA -->
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>jira-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${jira.version}</productVersion>
                    <productDataVersion>${jira.version}</productDataVersion>
                    <productDataPath>${maven.multiModuleProjectDirectory}/test-resources/jira-generated-test-resources.zip
                    </productDataPath>
                    <skipITs>true</skipITs>
                    <enableQuickReload>true</enableQuickReload>
                    <startupTimeout>1800000</startupTimeout>
                    <jvmArgs>-Xms2g -Xmx4g -XX:+UseG1GC</jvmArgs>
                    <contextPath>/</contextPath>
                    <productLicense>${jira.service.management.license}</productLicense>
                    <httpPort>${jira.http.port}</httpPort>
                    <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Export-Package>
                            com.linkedplanet.plugin.jira.jiraclient.test.api,
                        </Export-Package>
                        <Import-Package>
                            org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            *;version="0";resolution:=optional
                        </Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                    <applications>
                        <application>
                            <applicationKey>jira-software</applicationKey>
                            <version>${jira.version}</version>
                        </application>
                        <application>
                            <applicationKey>jira-servicedesk</applicationKey>
                            <version>${servicedesk.version}</version>
                        </application>
                    </applications>
                    <systemPropertyVariables>
                        <atlassian.mail.senddisabled>false</atlassian.mail.senddisabled>
                    </systemPropertyVariables>
                </configuration>
            </plugin>

            <!-- SPRING SCANNER -->
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>${atlassian.spring.scanner.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <verbose>false</verbose>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>show-home-warning</id>
                        <configuration>
                            <target>
                                <input message="ATTENTION!${line.separator}Remove the license information which is stored in the database. Therefore stop Jira, connect to the database (e.g. with IntelliJ) and finally remove the entries from the license tables.${line.separator}Press enter to continue..."/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- plugins we only want to execute on the CI server because they either take too
             long or cause problems locally -->
        <profile>
            <id>jira-ci-sdk</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>jira-maven-plugin</artifactId>
                        <configuration>
                            <skipITs>false</skipITs>
                            <enableQuickReload>false</enableQuickReload>
                        </configuration>
                    </plugin>

                    <!-- INTEGRATION TEST only for ci-profile -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <skipTests>false</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
