<?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">
    <parent>
        <artifactId>atlassian-secrets</artifactId>
        <groupId>com.atlassian.secrets</groupId>
        <version>7.0.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <packaging>atlassian-plugin</packaging>

    <artifactId>atlassian-secrets-manager</artifactId>

    <name>Atlassian Secrets Manager</name>
    <description>A plugin for managing product related secrets via the Atlassian Secret Service</description>

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

    <dependencies>
        <dependency>
            <groupId>com.atlassian.event</groupId>
            <artifactId>atlassian-event</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-javaconfig</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- This is just used for the annotations, while they aren't actually provided by the product, the JVM ignores any annotations
     that aren't present at runtime. The annotations are processed by swagger-maven-plugin during the build. -->
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.secrets</groupId>
            <artifactId>atlassian-secrets-public-api</artifactId>
            <!-- Ensure plugin version and lib version are synced -->
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.secrets</groupId>
            <artifactId>atlassian-secrets-api</artifactId>
            <!-- Ensure plugin version and lib version are synced -->
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.secrets</groupId>
            <artifactId>atlassian-secrets-service</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.analytics</groupId>
            <artifactId>analytics-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-v2-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.audit</groupId>
            <artifactId>atlassian-audit-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <scope>provided</scope>
        </dependency>
        <!--   Test deps    -->
        <dependency>
            <groupId>biz.aQute.bnd</groupId>
            <artifactId>biz.aQute.bndlib</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.beehive</groupId>
            <artifactId>beehive-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>tools.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-lts8on</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-maven-plugin-jakarta</artifactId>
                <version>${swagger.version}</version>
                <configuration>
                    <outputFileName>swagger</outputFileName>
                    <outputPath>${project.basedir}/src/main/resources/swagger/swagger-generated</outputPath>
                    <outputFormat>JSONANDYAML</outputFormat>
                    <configurationFilePath>${project.basedir}/src/main/resources/swagger/swagger.config.yaml
                    </configurationFilePath>
                    <resourceClasses>
                        <resourceClass>com.atlassian.secrets.manager.rest.KeysResource</resourceClass>
                    </resourceClasses>
                </configuration>
                <executions>
                    <execution>
                        <id>swagger-resolve</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>resolve</goal>
                        </goals>
                    </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>
                    <product>${product}</product>
                    <server>localhost</server>
                    <products>
                        <product>
                            <id>bitbucket</id>
                            <version>${bitbucket.run.version}</version>
                            <productDataVersion>${bitbucket.run.version}</productDataVersion>
                            <httpPort>${bitbucket.http.port}</httpPort>
                            <jvmArgs>
                                ${jvmHeap} ${jvm17.opens} -Dplugin.audit.internal.testing.no.permissions=true
                            </jvmArgs>
                        </product>
                        <product>
                            <id>confluence</id>
                            <version>${confluence.run.version}</version>
                            <productDataVersion>${confluence.run.version}</productDataVersion>
                            <httpPort>${confluence.http.port}</httpPort>
                            <systemPropertyVariables>
                                <!-- Disabled since it's not related to Lighthouse and emits too many errors and noisy logs-->
                                <synchrony.btf.disabled>true</synchrony.btf.disabled>
                            </systemPropertyVariables>
                            <jvmArgs>
                                ${jvmHeap}
                                ${jvm17.opens}
                                <!-- Tune the JVM a bit for Confluence to be quick -->
                                -XX:+UseG1GC
                                -XX:G1HeapRegionSize=32M
                                -XX:G1ReservePercent=20
                                -XX:+UseGCOverheadLimit
                                -XX:+ExplicitGCInvokesConcurrent
                                -XX:+HeapDumpOnOutOfMemoryError
                                -XX:+ExitOnOutOfMemoryError
                                -XX:+DisableExplicitGC
                                <!-- Enable site and user-level dark features UI -->
                                -DclusterMode=false
                                -Datlassian.darkfeature.confluence.onboarding.bypass=true
                                -Datlassian.darkfeature.confluence.pulp=true
                                -Dtroubleshooting.dev.mode=true
                                -Dbaseurl=http://localhost:1990/confluence
                                -Dhide.system.error.details=false
                                <!-- disabled annoying and spammy "Thread method sampler crashed" log message -->
                                -Datlassian.darkfeature.com.atlassian.troubleshooting.jfr.disabled=true
                                <!-- Auditing specific settings -->
                                -Dplugin.audit.internal.testing.no.permissions=true
                            </jvmArgs>
                        </product>
                        <product>
                            <id>jira</id>
                            <version>${jira.run.version}</version>
                            <productDataVersion>${jira.run.version}</productDataVersion>
                            <httpPort>${jira.http.port}</httpPort>
                            <jvmArgs>
                                ${jvmHeap}
                                -XX:+UseG1GC
                                -XX:+DisableExplicitGC
                                <!-- Prevent a bunch of annoying warnings and flags getting in the way in both the UI and logs -->
                                -Datlassian.darkfeature.jira.onboarding.feature.disabled=true
                                -Djira.startup.warnings.disable=true -Dtroubleshooting.dev.mode=true
                                <!-- Enable site and user-level dark features UI -->
                                -Datlassian.darkfeature.jira.site.darkfeature.admin=true
                                -Datlassian.darkfeature.jira.user.darkfeature.admin=true
                                <!-- Prevent annoying warnings in the console -->
                                -Dmail.mime.decodeparameters=true
                                -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true
                                <!-- Auditing specific settings -->
                                -Dcom.atlassian.jira.advanced.audit.log.enabled
                                -Dplugin.audit.internal.testing.no.permissions=true
                                <!-- disabled annoying and spammy "Thread method sampler crashed" log message -->
                                -Datlassian.darkfeature.com.atlassian.troubleshooting.jfr.disabled=true
                                <!-- Enable sending emails for ITs-->
                                -Datlassian.mail.senddisabled=false
                            </jvmArgs>
                        </product>
                        <product>
                            <id>refapp</id>
                            <version>${refapp.version}</version>
                            <httpPort>${refapp.http.port}</httpPort>
                            <jvmArgs>
                                -Dproduct=refapp ${jvm17.opens}
                            </jvmArgs>
                        </product>
                    </products>
                    <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>

                        <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.service.*;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",

                            <!-- Wildcard import for all other packages -->
                            *
                        </Import-Package>

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>run-bitbucket</id>
            <properties>
                <product>bitbucket</product>
            </properties>
        </profile>
        <profile>
            <id>run-confluence</id>
            <properties>
                <product>confluence</product>
            </properties>
        </profile>
        <profile>
            <id>run-jira</id>
            <properties>
                <product>jira</product>
            </properties>
        </profile>
    </profiles>
</project>