<?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-plugins-webresource-parent</artifactId>
        <version>9.0.0-java25-m009-83f7837035b</version>
    </parent>

    <artifactId>atlassian-plugins-webresource-rest</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Atlassian Plugins - Web Resources REST</name>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <contract.testing.location>${basedir}/contract-testing</contract.testing.location>
        <node.path>${project.parent.basedir}/.node</node.path>
        <sonar.coverage.jacoco.xmlReportPaths>${project.parent.basedir}${jacoco.report.file}</sonar.coverage.jacoco.xmlReportPaths>
        <swagger.location>${project.build.directory}/swagger-generated</swagger.location>
    </properties>

    <dependencies>
        <!-- project -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource-common</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- java/jakarta -->
        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- platform 1st party -->
        <dependency>
            <groupId>com.atlassian.annotations</groupId>
            <artifactId>atlassian-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.json</groupId>
            <artifactId>atlassian-json-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.plugins.rest</groupId>
            <artifactId>atlassian-rest-v2-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- platform 3rd party -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</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.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- outside platform -->
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations-jakarta</artifactId>
            <version>${swagger.version}</version>
            <scope>compile</scope>
        </dependency>
        <!-- test dependencies -->
        <dependency>
            <groupId>io.atlassian.fugue</groupId>
            <artifactId>fugue</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <scope>test</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>
                    <includedFeModuleManifests>
                        <includedFeModuleManifest>${project.basedir}/package.json</includedFeModuleManifest>
                        <includedFeModuleManifest>${project.basedir}/../yarn.lock</includedFeModuleManifest>
                    </includedFeModuleManifests>
                    <feManifestAssociations>
                        <feManifestAssociation>
                            <packageName>@atlassian/atlassian-plugins-webresource-rest</packageName>
                            <manuallyVerifiedEveryFileHasItsDependenciesDeclaredInTheManifest>
                                <outputDirectoryFiles>
                                    <file>js/dist/data-collector-async.js</file>
                                    <file>js/dist/data-collector-async.min.js</file>
                                    <file>js/dist/data-collector-perf-observer.js</file>
                                    <file>js/dist/data-collector-perf-observer.min.js</file>
                                    <file>js/dist/wrm.js</file>
                                    <file>js/dist/wrm.min.js</file>
                                </outputDirectoryFiles>
                            </manuallyVerifiedEveryFileHasItsDependenciesDeclaredInTheManifest>
                        </feManifestAssociation>
                    </feManifestAssociations>
                    <compressJs>false</compressJs>
                    <jvmArgs>${jacoco.it.argLine}</jvmArgs>
                    <skipRestDocGeneration>true</skipRestDocGeneration>
                    <products>
                        <product>
                            <id>jira</id>
                            <version>${jira.version}</version>
                        </product>
                        <product>
                            <id>refapp</id>
                            <instanceId>refapp</instanceId>
                            <version>${refapp.version}</version>
                            <output>${project.build.directory}/refapp.log</output>
                        </product>
                    </products>
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Private-Package>com.atlassian.webresource.plugin</Private-Package>
                        <Import-Package>com.atlassian.html.encode*,
                            com.atlassian.json.marshal.*,
                            com.atlassian.plugin.*,
                            com.atlassian.plugin.servlet*,
                            com.atlassian.plugin.webresource*;version="${wrm.api.compat.version}",
                            com.atlassian.plugin.webresource.graph*,
                            com.atlassian.sal.api.features;version="${sla.api.osgi.version}",
                            com.atlassian.webresource.api*;version="${wrm.api.compat.version}",
                            com.google.gson;resolution:="optional",
                            com.google.gson.*;resolution:="optional",
                            io.swagger.v3.oas.annotations;resolution:="optional",
                            io.swagger.v3.oas.annotations.*;resolution:="optional",
                            com.google.common.*,
                            io.atlassian.util.concurrent,
                            javax.naming.*,
                            javax.net.*,
                            javax.net.ssl.*,
                            javax.security.auth.*,
                            jakarta.ws.rs*,
                            org.apache.commons.collections,
                            org.apache.commons.io,
                            org.apache.commons.lang3,
                            org.apache.commons.lang3.exception,
                            org.apache.http.*,
                            org.codehaus.jackson*,
                            org.slf4j,
                            *</Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
                <executions>
                    <execution>
                        <id>js-enforcement</id>
                        <goals>
                            <goal>verify-fe-manifest-associations</goal>
                        </goals>
                        <phase>verify</phase>
                        <configuration>
                            <verifyFeManifestAssociationsInputEntrypoint>
                                ${project.build.directory}/${project.build.finalName}.jar
                            </verifyFeManifestAssociationsInputEntrypoint>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${frontend.maven.plugin.version}</version>
                <configuration>
                    <installDirectory>${node.path}</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>contract-install-node-dependencies</id>
                        <goals>
                            <goal>corepack</goal>
                        </goals>
                        <phase>process-test-resources</phase>
                        <configuration>
                            <arguments>${frontend.install.cmd}</arguments>
                            <workingDirectory>${contract.testing.location}</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>contract-sort-generated-swagger-specs</id>
                        <goals>
                            <goal>corepack</goal>
                        </goals>
                        <phase>process-test-resources</phase>
                        <configuration>
                            <arguments>yarn run lint:sort</arguments>
                            <workingDirectory>${contract.testing.location}</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>contract-validate</id>
                        <goals>
                            <goal>corepack</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <arguments>yarn run validate</arguments>
                            <workingDirectory>${contract.testing.location}</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>contract-share</id>
                        <goals>
                            <goal>corepack</goal>
                        </goals>
                        <phase>deploy</phase>
                        <configuration>
                            <arguments>yarn run share</arguments>
                            <workingDirectory>${contract.testing.location}</workingDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-maven-plugin-jakarta</artifactId>
                <version>${swagger.version}</version>
                <configuration>
                    <outputFormat>JSON</outputFormat>
                    <outputPath>${swagger.location}</outputPath>
                </configuration>
                <executions>
                    <execution>
                        <id>swagger-private-one-zero-resolve</id>
                        <goals>
                            <goal>resolve</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <resourcePackages>
                                <resourcePackage>com.atlassian.webresource.plugin.rest.one.zero</resourcePackage>
                            </resourcePackages>
                            <outputFileName>swagger.private.one.zero</outputFileName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>swagger-private-two-zero-resolve</id>
                        <goals>
                            <goal>resolve</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <resourcePackages>
                                <resourcePackage>com.atlassian.webresource.plugin.rest.two.zero</resourcePackage>
                            </resourcePackages>
                            <outputFileName>swagger.private.two.zero</outputFileName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>yarn-build</id>
            <activation>
                <property>
                    <name>!skipBuild</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>build-frontend</id>
                                <goals>
                                    <goal>corepack</goal>
                                </goals>
                                <phase>compile</phase>
                                <configuration>
                                    <arguments>yarn run build</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>yarn-tests</id>
            <activation>
                <property>
                    <name>!skipUTs</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>test-frontend</id>
                                <goals>
                                    <goal>corepack</goal>
                                </goals>
                                <phase>test</phase>
                                <configuration>
                                    <arguments>yarn run test:ci</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>