<?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>

    <parent>
        <groupId>com.atlassian.oauth2</groupId>
        <artifactId>oauth2-client-parent</artifactId>
        <version>1.0.0-m05</version>
    </parent>

    <artifactId>oauth2-client-plugin</artifactId>

    <name>Atlassian OAuth 2 Client - Plugin</name>
    <description>Plugin for Atlassian OAuth 2 Client</description>

    <packaging>atlassian-plugin</packaging>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <nodeVersion>v12.16.1</nodeVersion>
        <yarnVersion>v1.22.0</yarnVersion>
        <yarn.cmd.install.dev>install --pure-lockfile --prefer-offline --mutex network</yarn.cmd.install.dev>
        <yarn.cmd.install>install --frozen-lockfile --prefer-offline --mutex network --no-progress</yarn.cmd.install>
        <yarn.cmd.build>build</yarn.cmd.build>
        <yarn.cmd.build.dev>build:dev</yarn.cmd.build.dev>
        <eirslett.frontend.version>1.9.1</eirslett.frontend.version>
        <frontend.maven.plugin.install.directory>${project.build.directory}</frontend.maven.plugin.install.directory>
        <frontend.working.directory>frontend</frontend.working.directory>
        <soy.template.version>5.0.0</soy.template.version>
        <webresource.version>3.5.6</webresource.version>
        <seraph.version>3.0.3</seraph.version>
        <keycloak.version>9.0.0</keycloak.version>
        <resteasy.version>3.9.1.Final</resteasy.version>
        <!-- KRAK-3251 -->
        <product.jvmArgs>-Datlassian.darkfeature.atlassian.oauth2.client.skip.https.requirement=true -Djavax.net.ssl.trustStore=${project.basedir}/src/test/resources/keycloak/cacerts -Djavax.net.ssl.trustStorePassword=changeit</product.jvmArgs>
<!--         <skipITs>true</skipITs> -->
        <xvfb.enable>true</xvfb.enable>
        <atlassian.webdriver.version>2.5.3</atlassian.webdriver.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.google.code.gson</groupId>
                    <artifactId>gson</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.json</groupId>
            <artifactId>atlassian-json-api</artifactId>
            <version>0.9</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.seraph</groupId>
            <artifactId>atlassian-seraph</artifactId>
            <version>${seraph.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.oauth2</groupId>
            <artifactId>oauth2-client-api</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.oauth2</groupId>
            <artifactId>oauth2-client-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.oauth2</groupId>
            <artifactId>oauth2-client-rest</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <version>${atlassian.active.objects.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>${jaxb.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.scheduler</groupId>
            <artifactId>atlassian-scheduler-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Tests -->
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>${restassured.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20080701</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-admin-client</artifactId>
            <version>${keycloak.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>${resteasy.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson2-provider</artifactId>
            <version>${resteasy.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>4.0.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.selenium</groupId>
            <artifactId>atlassian-webdriver-core</artifactId>
            <version>${atlassian.webdriver.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.google.collections</groupId>
                    <artifactId>google-collections</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit-dep</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${eirslett.frontend.version}</version>
                <configuration>
                    <nodeVersion>${nodeVersion}</nodeVersion>
                    <yarnVersion>${yarnVersion}</yarnVersion>
                    <installDirectory>${frontend.maven.plugin.install.directory}</installDirectory>
                    <workingDirectory>${frontend.working.directory}</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install-node-and-yarn</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>install-prod-dependencies</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>${yarn.cmd.install}</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile-the-ui</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>${yarn.cmd.build}</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn type-check</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>run type-check</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>run-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>test</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>amps-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <enableQuickReload>true</enableQuickReload>
                    <log4jProperties>src/main/resources/log4j-oauth2.properties</log4jProperties>
                    <libArtifacts>
                        <libArtifact>
                            <groupId>com.atlassian.oauth2</groupId>
                            <artifactId>oauth2-client-api</artifactId>
                            <version>${project.version}</version>
                        </libArtifact>
                    </libArtifacts>

                    <pluginArtifacts>
                        <pluginArtifact>
                            <groupId>com.atlassian.oauth2</groupId>
                            <artifactId>oauth2-client-test-plugin</artifactId>
                            <version>${project.version}</version>
                        </pluginArtifact>
                    </pluginArtifacts>

                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                        <Import-Package>
                            org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            com.atlassian.seraph.config.*;resolution:="optional",
                            com.atlassian.oauth2.client.api.*,
                            com.atlassian.plugins.osgi.javaconfig.*;resolution:="optional",

                            <!-- exclude pocketknife bits we don't need -->
                            !net.sf.cglib.proxy,
                            !org.jvnet.hudson.annotation_indexer,
                            !com.google.gson.stream,
                            !com.google.crypto.tink.subtle,
                            !com.ibm.uvm.tools,
                            !com.sun.jdmk.comm,
                            !javax.jmdns,
                            !javax.jms,
                            !net.sf.ehcache,
                            !net.spy.memcached,
                            !net.shibboleth.*,
                            !org.apache.avalon.framework*,
                            !org.apache.log,
                            !org.cryptomator.*,
                            !sun.security.util,
                            !com.mysema.query.*,
                            !com.mysema.query.spatial.path,
                            !com.mysema.query.spatial,
                            !org.postgis,
                            !org.bouncycastle.*,
                            !org.opensaml.*,
                            !oracle.spatial.geometry,
                            !org.geolatte.geom,
                            !org.geolatte.geom.codec,
                            !org.geolatte.geom.crs,
                            !bsh,
                            !sun.misc,

                            *
                        </Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>

                    <systemPropertyVariables>
                        <xvfb.enable>${xvfb.enable}</xvfb.enable>
                        <trimStackTrace>false</trimStackTrace>
                        <es.insecure.allow.root>true</es.insecure.allow.root>
                    </systemPropertyVariables>
                    <server>localhost</server>

                    <products>
                        <product>
                            <id>refapp</id>
                            <instanceId>refapp</instanceId>
                            <jvmArgs>${product.jvmArgs}</jvmArgs>
                        </product>
                        <product>
                            <id>jira</id>
                            <instanceId>jira</instanceId>
                            <jvmArgs>${product.jvmArgs}</jvmArgs>
                        </product>
                        <product>
                            <id>confluence</id>
                            <instanceId>confluence</instanceId>
                            <jvmArgs>${product.jvmArgs} -Xms1g -Xmx2g</jvmArgs>
                        </product>
                    </products>

                    <testGroups>
                        <testGroup>
                            <id>testgroup</id>
                            <productIds>
                                <productId>refapp</productId>
                            </productIds>
                            <excludes>
                                <exclude>it/com/atlassian/oauth2/client/integration/*.java</exclude>
                                <exclude>it/com/atlassian/oauth2/client/webdriver/tests/*.java</exclude>
                            </excludes>
                        </testGroup>
                    </testGroups>
                </configuration>
            </plugin>

            <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>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.oauth2</groupId>
                            <artifactId>oauth2-client-core</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>true</verbose>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>watch-mode</id>
            <properties>
                <yarn.cmd.install>${yarn.cmd.install.dev}</yarn.cmd.install>
                <yarn.cmd.build>${yarn.cmd.build.dev}</yarn.cmd.build>
            </properties>
        </profile>
        <profile>
            <id>e2e-tests</id>
            <properties>
                <docker.keycloak.skip>false</docker.keycloak.skip>
<!--                 <skipITs>false</skipITs> -->
                <debug.analytics>true</debug.analytics>
                <jvm.args.custom>-Djavax.net.ssl.trustStore=${project.build.testOutputDirectory}/keycloak/cacerts -Djavax.net.ssl.trustStorePassword=changeit</jvm.args.custom>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <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>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
