<?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.monitoring.and.alerting</groupId>
        <artifactId>atlassian-monitoring-and-alerting</artifactId>
        <version>1.2.6</version>
    </parent>

    <artifactId>atlassian-lighthouse-plugin</artifactId>
    <name>Atlassian Security Monitoring and Alerts Plugin</name>

    <packaging>atlassian-plugin</packaging>

    <properties>
        <!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
    </properties>

    <repositories>
        <repository>
            <id>mavenCentral</id>
            <url>https://repo1.maven.org/maven2/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.monitoring.and.alerting</groupId>
            <artifactId>atlassian-lighthouse-core</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.monitoring.and.alerting</groupId>
            <artifactId>atlassian-lighthouse-frontend</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.monitoring.and.alerting</groupId>
            <artifactId>atlassian-lighthouse-rest</artifactId>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>amps-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <product>${product}</product>
                    <enableQuickReload>true</enableQuickReload>
                    <server>localhost</server>
                    <skipITs>true</skipITs>
                    <platformVersion>${platform.version}</platformVersion>

                    <!-- See here for an explanation of default instructions: -->
                    <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>

                        <Export-Package>
                            com.atlassian.lighthouse.security.consumer,
                            com.atlassian.lighthouse.matchers.*
                        </Export-Package>
                        <Import-Package>
                            org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            com.google.gson.*;resolution:="optional",
                            com.atlassian.user;resolution:="optional",
                            com.atlassian.plugins.whitelist.*;resolution:="optional",
                            com.atlassian.plugins.whitelist.events.*;resolution:="optional",
                            com.atlassian.audit.core.spi.*;resolution:="optional",
                            com.atlassian.audit.core.spi.service.*;resolution:="optional",
                            com.atlassian.plugin.osgi.container.*;resolution:="optional",
                            <!-- Bitbucket -->
                            com.atlassian.bitbucket.auth.*;resolution:="optional",
                            com.atlassian.bitbucket.cluster.*;resolution:="optional",
                            com.atlassian.bitbucket.event.*;resolution:="optional",
                            com.atlassian.bitbucket.server.*;resolution:="optional",
                            com.atlassian.bitbucket.nav.*;resolution:="optional",
                            com.atlassian.bitbucket.mail.*;resolution:="optional",
                            com.atlassian.bitbucket.permission.*;resolution:="optional",
                            com.atlassian.bitbucket.request.*;resolution:="optional",
                            com.atlassian.bitbucket.user.*;resolution:="optional",
                            com.atlassian.bitbucket.util.*;resolution:="optional",
                            <!-- Jira -->
                            com.atlassian.jira.event.*;resolution:="optional",
                            com.atlassian.jira.security.*;resolution:="optional",
                            com.atlassian.jira.user.*;resolution:="optional",
                            com.atlassian.mail;resolution:="optional",
                            com.atlassian.jira.config.properties;resolution:="optional",
                            com.atlassian.jira.database;resolution:="optional",
                            com.atlassian.jira.permission;resolution:="optional",
                            com.atlassian.jira.util.thread;resolution:="optional",
                            <!-- Confluence -->
                            com.atlassian.confluence.api.model;resolution:="optional",
                            com.atlassian.confluence.api.model.pagination;resolution:="optional",
                            com.atlassian.confluence.api.model.people;resolution:="optional",
                            com.atlassian.confluence.api.service.people;resolution:="optional",
                            com.atlassian.confluence.cluster;resolution:="optional",
                            com.atlassian.confluence.dmz.security.delegate;resolution:="optional",
                            com.atlassian.confluence.event.events.*;resolution:="optional",
                            com.atlassian.confluence.security.*;resolution:="optional",
                            com.atlassian.confluence.setup.settings;resolution:="optional",
                            com.atlassian.confluence.user.*;resolution:="optional",
                            com.atlassian.confluence.spaces;resolution:="optional",
                            com.atlassian.confluence.util;resolution:="optional",
                            com.atlassian.core.task;resolution:="optional",
                            <!-- Jira & Confluence -->
                            com.atlassian.mail.queue;resolution:="optional",
                            <!-- Swagger annotations are needed at build time but not at runtime (and are not available),
                                 so we mark them as optional to avoid runtime errors -->
                            io.swagger.v3.oas.annotations.*;resolution:="optional",

                            <!-- Never try to import kotlin, we bundle it into the plugin instead. -->
                            !kotlin.*,
                            <!-- Kotlin's SDK uses reflection to determine the Android SDK version, this is detected by BND, and
                                 causes android.os to be added to the wildcard imports if not explicitly rejected, as we do below. -->
                            !android.*,
                            <!-- Wildcard import for all other packages -->
                            *
                        </Import-Package>

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                    <includedFeModuleManifests>
                        <includedFeModuleManifest>../atlassian-lighthouse-frontend/package.json</includedFeModuleManifest>
                        <includedFeModuleManifest>../atlassian-lighthouse-frontend/yarn.lock</includedFeModuleManifest>
                    </includedFeModuleManifests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <configuration>
                    <installDirectory>${frontend.maven.plugin.install.directory}</installDirectory>
                    <workingDirectory>${frontend.working.directory}</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>build-frontend</id>
                        <!-- We want yarn to run in the compile phase as it's a natural point to run it and gives us
                             plenty of phases both before, and after to hook into. -->
                        <phase>${phase.compile}</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>${frontend.cmd.build}</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
        </plugins>
    </build>
</project>
