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

    <artifactId>atlassian-gadgets-publisher-plugin</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Gadget Spec Publisher Plugin</name>
    <description>Plugin which provides a way to publish gadget specs found in plugins</description>

    <properties>
        <soy.version>20100708</soy.version>
        <atlassian.plugin.key>com.atlassian.gadgets.publisher</atlassian.plugin.key>
        <sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../${jacoco.report.file}</sonar.coverage.jacoco.xmlReportPaths>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Compile-time, bundled dependencies -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>atlassian-gadgets-shared</artifactId>
        </dependency>

        <!-- Provided, non-bundled dependencies -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>atlassian-gadgets-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>atlassian-gadgets-spi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</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</groupId>
            <artifactId>atlassian-plugins-webfragment</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi</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>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.json</groupId>
            <artifactId>atlassian-json-api</artifactId>
            <version>0.11</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.html</groupId>
            <artifactId>atlassian-html-encoder</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.cache</groupId>
            <artifactId>atlassian-cache-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency><!-- provided by platform public-api -->
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency><!-- provided by platform public-api -->
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-v2-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.rometools</groupId>
            <artifactId>rome</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Test-only dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>atlassian-gadgets-test-framework</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>refapp-maven-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Bundle-SymbolicName>${atlassian.plugin.key}</Bundle-SymbolicName>
                        <Spring-Context>*</Spring-Context>
                        <Import-Package>
                            javax.xml.bind*,
                            com.atlassian.plugin.osgi.bridge.external,
                            *
                        </Import-Package>
                        <Private-Package>
                            com.atlassian.gadgets.publisher.internal.*,
                            com.atlassian.gadgets.util
                        </Private-Package>
                    </instructions>
                    <skipManifestValidation>true</skipManifestValidation>
                    <includedFeModuleManifests>
                        <includedFeModuleManifest>${project.basedir}/package.json</includedFeModuleManifest>
                        <includedFeModuleManifest>${project.basedir}/yarn.lock</includedFeModuleManifest>
                    </includedFeModuleManifests>
                    <feManifestAssociations>
                        <feManifestAssociation>
                            <outputDirectoryFilesDeclaration>
                                ${project.basedir}/src/main/frontend/fe-manifest-associations.json
                            </outputDirectoryFilesDeclaration>
                        </feManifestAssociation>
                    </feManifestAssociations>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.sf.alchim</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
                <configuration>
                    <executable>${java.home}/bin/java</executable>
                    <arguments>
                        <argument>-jar</argument>
                        <argument>${settings.localRepository}/com/google/template/soy/SoyToJsSrcCompiler/${soy.version}/SoyToJsSrcCompiler-${soy.version}.jar</argument>
                        <argument>--outputPathFormat</argument>
                        <argument>${project.basedir}/target/classes/templates/messages/{INPUT_FILE_NAME_NO_EXT}.js</argument>
                        <argument>${project.basedir}/src/main/resources/templates/messages/error.soy</argument>
                        <argument>${project.basedir}/src/main/resources/templates/messages/warning.soy</argument>
                        <argument>${project.basedir}/src/main/resources/templates/messages/info.soy</argument>
                    </arguments>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.google.template.soy</groupId>
                        <artifactId>SoyToJsSrcCompiler</artifactId>
                        <version>${soy.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install node and yarn</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>yarn install</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>install --frozen-lockfile</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn-build</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>build</arguments>
                            <environmentVariables>
                                <NODE_ENV>production</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>soy.jvm.opens.activation</id>
            <activation>
                <jdk>[17,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <configuration>
                            <arguments>
                                <argument>--add-opens=java.base/java.lang=ALL-UNNAMED</argument>
                                <argument>-jar</argument>
                                <argument>${settings.localRepository}/com/google/template/soy/SoyToJsSrcCompiler/${soy.version}/SoyToJsSrcCompiler-${soy.version}.jar</argument>
                                <argument>--outputPathFormat</argument>
                                <argument>${project.basedir}/target/classes/templates/messages/{INPUT_FILE_NAME_NO_EXT}.js</argument>
                                <argument>${project.basedir}/src/main/resources/templates/messages/error.soy</argument>
                                <argument>${project.basedir}/src/main/resources/templates/messages/warning.soy</argument>
                                <argument>${project.basedir}/src/main/resources/templates/messages/info.soy</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
