<?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-insight-client</artifactId>
        <version>0.11.0</version>
    </parent>

    <artifactId>kotlin-insight-client-test-applink</artifactId>
    <name>kotlin-insight-client-test-applink</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>

        <confluence.http.port>1990</confluence.http.port>
    </properties>

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

        <dependency>
            <groupId>com.linked-planet.client</groupId>
            <artifactId>kotlin-insight-client-http</artifactId>
            <version>${project.version}</version>
        </dependency>

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

        <!-- External -->
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <version>${confluence.version}</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>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</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>com.atlassian.applinks</groupId>
            <artifactId>applinks-api</artifactId>
            <version>7.2.3</version>
            <scope>provided</scope>
        </dependency>

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

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2-atlassian-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>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.atlassian.maven.plugins</groupId>
                    <artifactId>confluence-maven-plugin</artifactId>
                    <version>${amps.version}</version>
                </plugin>
                <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>

            <!-- CONFLUENCE -->
            <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.version}</productDataVersion>
                    <productDataPath>${maven.multiModuleProjectDirectory}/test-resources/confluence-generated-test-resources.zip
                    </productDataPath>
                    <skipITs>true</skipITs>
                    <enableQuickReload>true</enableQuickReload>
                    <allowGoogleTracking>false</allowGoogleTracking>
                    <jvmArgs>-Xms2g -Xmx4g</jvmArgs>
                    <server>localhost</server>
                    <httpPort>${confluence.http.port}</httpPort>
                    <ajpPort>8010</ajpPort>
                    <jvmDebugPort>5006</jvmDebugPort>
                    <startupTimeout>1800000</startupTimeout>
                    <contextPath>/</contextPath>
                    <productLicense>${confluence.license}</productLicense>
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Export-Package>
                            com.linkedplanet.plugin.confluence.jiraclient.test.api,
                        </Export-Package>
                        <Import-Package>
                            !junit.*,
                            !org.junit.*,
                            !sun.misc.*,
                            !com.sun.*,
                            !io.ktor.*,
                            !jdk.internal.*,
                            !org.jetbrains.*,
                            !org.joda.convert.*,
                            *
                        </Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </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>

            <!-- Show reminder for license removal on create-home-zip -->
            <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 created zip in 'confluence.cfg.xml'.${line.separator}Set entry 'atlassian.license.message' to 'TBD'.${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>insight-ci-applink</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>confluence-maven-plugin</artifactId>
                        <configuration>
                            <skipITs>false</skipITs>
                            <enableQuickReload>false</enableQuickReload>
                            <enablePde>false</enablePde>
                            <enableDevToolbox>false</enableDevToolbox>
                            <enablePluginViewer>false</enablePluginViewer>
                        </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>
