<?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.plugins</groupId>
        <artifactId>atlassian-clientside-extensions-parent</artifactId>
        <version>2.4.0-e0cce94-kuewz5ow</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>atlassian-clientside-extensions-runtime</artifactId>
    <name>Atlassian Plugins - Client-side Extensions - Runtime</name>
    <description>Provides a registry and runtime to enable client-side extensions.</description>
    <packaging>atlassian-plugin</packaging>
    <licenses>
        <license>
            <name>BSD License</name>
            <url>http://opensource.org/licenses/BSD-3-Clause</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <build>
        <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.version}</productDataVersion>
                    <enableQuickReload>true</enableQuickReload>
                    <closureJsCompiler>true</closureJsCompiler>
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>

                        <Private-Package>
                            com.atlassian.plugins.client*,
                            com.atlassian.rest.plugins*
                        </Private-Package>

                        <!-- Add package import here -->
                        <Import-Package>
                            com.atlassian.plugin.osgi.bridge.external,
                            com.atlassian.plugin.descriptors,
                            com.atlassian.plugin.web.api.*,
                            com.atlassian.json.*,
                            com.atlassian.plugin.*,
                            *
                        </Import-Package>

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>

                    <!-- When testing this module, these will cause AMPS to install versions of
                         non-plugin artifacts we know we need in order for this plugin to work.
                         See https://developer.atlassian.com/server/framework/atlassian-sdk/amps-build-configuration-reference/ -->
                    <libArtifacts>
                        <libArtifact>
                            <groupId>com.atlassian.plugins</groupId>
                            <artifactId>atlassian-plugins-webfragment</artifactId>
                            <version>${webfragments.version}</version>
                        </libArtifact>

                        <libArtifact>
                            <groupId>com.atlassian.plugins</groupId>
                            <artifactId>atlassian-plugins-webfragment-api</artifactId>
                            <version>${webfragments.version}</version>
                        </libArtifact>

                        <libArtifact>
                            <groupId>com.atlassian.plugins</groupId>
                            <artifactId>atlassian-plugins-webresource</artifactId>
                            <version>${webresources.version}</version>
                        </libArtifact>

                        <libArtifact>
                            <groupId>com.atlassian.plugins</groupId>
                            <artifactId>atlassian-plugins-webresource-api</artifactId>
                            <version>${webresources.version}</version>
                        </libArtifact>
                    </libArtifacts>

                    <!-- When testing this module, these will cause AMPS to install versions of
                         Atlassian Plugin artifacts we know we need in order for this plugin to work.
                         See https://developer.atlassian.com/server/framework/atlassian-sdk/amps-build-configuration-reference/ -->
                    <pluginArtifacts>
                        <pluginArtifact>
                            <groupId>com.atlassian.plugins</groupId>
                            <artifactId>atlassian-plugins-webresource-plugin</artifactId>
                            <version>${webresources.version}</version>
                        </pluginArtifact>

                        <pluginArtifact>
                            <groupId>com.atlassian.plugins</groupId>
                            <artifactId>atlassian-plugins-webresource-rest</artifactId>
                            <version>${webresources.version}</version>
                        </pluginArtifact>
                    </pluginArtifacts>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <configuration>
                    <workingDirectory>${project.basedir}</workingDirectory>
                    <installDirectory>${project.parent.build.outputDirectory}</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>step-4-compile-the-ui</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>build</arguments>
                        </configuration>
                        <phase>process-resources</phase>
                    </execution>
                </executions>
            </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>
                        <!-- process-classes seems to be skipped if you are using scala
                             so perhaps use prepare-package -->
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <!-- Enable this to get build-time logging of annotations atlassian-spring-scanner-maven-plugin has noticed -->
                    <verbose>true</verbose>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>3.12.4</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </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-osgi</artifactId>
            <scope>provided</scope>
        </dependency>

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

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webfragment-api</artifactId>
            <scope>provided</scope>
            <version>${webfragments.version}</version>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <version>${webresources.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-common</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-core</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.ozymandias</groupId>
            <artifactId>atlassian-plugin-point-safety</artifactId>
            <version>${atlassian.ozymandias.version}</version>
        </dependency>

        <dependency>
            <groupId>com.atlassian.seraph</groupId>
            <artifactId>atlassian-seraph</artifactId>
            <version>${seraph.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>${jaxb.version}</version>
            <scope>provided</scope>
        </dependency>

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

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.json</groupId>
            <artifactId>atlassian-json-api</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>jacoco-report</id>
            <activation>
                <property>
                    <name>report</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>agent-for-ut</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <propertyName>jacoco.agent.argLine</propertyName>
                                    <includes>
                                        <include>com/atlassian/rest/**</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>@{jacoco.agent.argLine}</argLine>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>
    </profiles>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <seraph.version>4.1.1</seraph.version>
        <jaxb.version>2.3.1</jaxb.version>
        <jsr311.version>1.1.1</jsr311.version>

        <!-- products we test in -->
        <jira.version>8.3.0</jira.version>
        <refapp.version>5.0.4</refapp.version>

        <!-- java + maven compilation settings -->
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>

        <!-- jacoco aggregate report -->
        <sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../${jacoco.report.file}</sonar.coverage.jacoco.xmlReportPaths>
    </properties>
</project>
