<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.atlassian.confluence.plugins</groupId>
        <artifactId>confluence-frontend-parent</artifactId>
        <version>19.2.22</version>
    </parent>

    <artifactId>confluence-frontend</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Confluence Frontend</name>
    <description>The plugin provides frontend API and core modules.</description>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <maven.test.skip>${skipTests}</maven.test.skip>
        <npm.build.skip>false</npm.build.skip>
        <npm.install.skip>false</npm.install.skip>
        <npm.test.skip>${maven.test.skip}</npm.test.skip>
        <sonar.javascript.lcov.reportPaths>target/coverage/lcov/lcov.info</sonar.javascript.lcov.reportPaths>
        <sonar.sources>src</sonar.sources>
        <super-batch.plugin.key>com.atlassian.confluence.plugins.confluence-super-batch</super-batch.plugin.key>
    </properties>

    <!-- If this plugin relies on unique compile or runtime dependencies
         uncomment this build element or jars will be missing from the META-INF/lib -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <id>delete-node-modules</id>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <phase>clean</phase>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>node_modules</directory>
                                    <includes>
                                        <include>*</include>
                                    </includes>
                                </fileset>
                            </filesets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>frontend-install</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <skip>${npm.install.skip}</skip>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>install</argument>
                                <argument>--no-audit</argument>
                                <argument>--no-fund</argument>
                                <argument>--prefer-offline</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>frontend-build</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <skip>${npm.build.skip}</skip>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>build</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>frontend-checks</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <skip>${npm.test.skip}</skip>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>checks</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.data.version}</productDataVersion>
                    <enableQuickReload>true</enableQuickReload>
                    <compressJs>true</compressJs>
                    <compressCss>true</compressCss>
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Import-Package>com.atlassian.confluence.languages,
                            com.atlassian.confluence.plugin.descriptor.web,
                            com.atlassian.confluence.plugin.descriptor.web.conditions,
                            com.atlassian.confluence.plugin.descriptor.web.conditions.user,
                            com.atlassian.confluence.plugin.descriptor.web.urlreadingconditions,
                            com.atlassian.confluence.setup.settings,
                            com.atlassian.confluence.user,
                            com.atlassian.confluence.util.i18n,
                            com.atlassian.plugin,
                            *</Import-Package>

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                    </instructions>
                    <includedFeModuleManifests>
                        <includedFeModuleManifest>${project.basedir}/package.json</includedFeModuleManifest>
                        <includedFeModuleManifest>${project.basedir}/package-lock.json</includedFeModuleManifest>
                    </includedFeModuleManifests>
                    <feManifestAssociations>
                        <feManifestAssociation>
                            <outputDirectoryFilesDeclaration>${project.basedir}/fe-associations-declaration.json</outputDirectoryFilesDeclaration>
                        </feManifestAssociation>
                    </feManifestAssociations>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>amps-maven-plugin</artifactId>
                <extensions>false</extensions>
                <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>
        </plugins>
    </build>
</project>
