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

    <artifactId>atlassian-diagnostics-plugin</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Atlassian Diagnostics - Plugin</name>
    <description>Atlassian Diagnostics UI and REST interface</description>
    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <atlassian.plugins.osgi.javaconfig.version>0.5.0</atlassian.plugins.osgi.javaconfig.version>
        <frontend.maven.plugin.version>1.15.1-atlassian-6</frontend.maven.plugin.version>
        <frontend.maven.plugin.install.directory>${project.build.directory}</frontend.maven.plugin.install.directory>
        <frontend.working.directory>${project.basedir}</frontend.working.directory>
        <frontend.build.mode>production</frontend.build.mode>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.atlassian.annotations</groupId>
            <artifactId>atlassian-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.event</groupId>
            <artifactId>atlassian-event</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.diagnostics</groupId>
            <artifactId>atlassian-diagnostics-api</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.diagnostics</groupId>
            <artifactId>atlassian-diagnostics-core</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-javaconfig</artifactId>
            <version>${atlassian.plugins.osgi.javaconfig.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webfragment-api</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.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.compendium</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <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>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</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>
        <dependency>
            <groupId>com.atlassian.analytics</groupId>
            <artifactId>analytics-api</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>amps-maven-plugin</artifactId>
                <configuration>
                    <extractDependencies>true</extractDependencies>
                    <containerId>${tomcat.version}</containerId>
                    <enableQuickReload>true</enableQuickReload>
                    <instructions>
                        <Atlassian-Plugin-Key>${project.groupId}.${project.artifactId}</Atlassian-Plugin-Key>
                        <Import-Package>
                            <!-- Import the diagnostics packages exported by the host application -->
                            com.atlassian.diagnostics.*,
                            com.atlassian.plugin.osgi.hostcomponents,
                            com.atlassian.plugin.web,
                            com.atlassian.sal.api.message,
                            com.google.common.base,
                            jakarta.annotation,
                            jakarta.ws.rs,
                            jakarta.ws.rs.core,
                            jakarta.ws.rs.ext,
                            jakarta.inject,
                            org.apache.commons.lang3*,
                            org.osgi.framework,
                            org.osgi.util.tracker,
                            org.slf4j,
                            *
                        </Import-Package>
                        <!-- Ensure plugin is spring powered - see https://extranet.atlassian.com/x/xBS9hQ -->
                        <Spring-Context>*</Spring-Context>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                    </instructions>
                    <includedFeModuleManifests>
                        <!-- Package descriptor of the frontend application -->
                        <includedFeModuleManifest>${project.basedir}/package.json</includedFeModuleManifest>
                        <!-- Required so all versions of all transitive dependencies are declared -->
                        <includedFeModuleManifest>${project.basedir}/yarn.lock</includedFeModuleManifest>
                    </includedFeModuleManifests>
                    <feManifestAssociations>
                        <feManifestAssociation>
                            <outputDirectoryFilesDeclaration>
                                ${project.basedir}/fe-associations-declaration.json
                            </outputDirectoryFilesDeclaration>
                        </feManifestAssociation>
                    </feManifestAssociations>
                </configuration>
                <executions>
                    <execution>
                        <id>copy-fe-module-manifests</id>
                        <goals>
                            <goal>copy-fe-module-manifests</goal>
                        </goals>
                    </execution>
                </executions>
            </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>
                    <environmentVariables>
                        <NODE_ENV>${frontend.build.mode}</NODE_ENV>
                    </environmentVariables>
                </configuration>
                <executions>
                    <execution>
                        <id>step-1-install-node-and-corepack</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>install-node-and-corepack</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>step-2-install-dependencies</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>corepack</goal>
                        </goals>
                        <configuration>
                            <arguments>yarn install --immutable</arguments>
                            <environmentVariables>
                                <NODE_ENV>development</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                    </execution>
                    <execution>
                        <id>check-frontend-dependencies-licenses</id>
                        <phase>test</phase>
                        <goals>
                            <goal>corepack</goal>
                        </goals>
                        <configuration>
                            <arguments>yarn run lint:licenses</arguments>
                            <environmentVariables>
                                <NODE_ENV>verify</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
