<?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-backup-and-restore-ui-parent</artifactId>
        <version>20.2.6</version>
    </parent>

    <artifactId>confluence-backup-and-restore-ui</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Confluence Backup and Restore UI Plugin</name>
    <description>This is the com.atlassian.confluence.plugins:confluence-backup-and-restore-ui plugin for Atlassian Confluence.</description>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <!--suppress UnresolvedMavenProperty -->
        <maven.test.skip>${skipTests}</maven.test.skip>
        <npm.build.script>build</npm.build.script>
        <npm.build.skip>false</npm.build.skip>
        <npm.install.skip>false</npm.install.skip>
        <npm.test.skip>${maven.test.skip}</npm.test.skip>
        <skipJacocoReport>false</skipJacocoReport>
        <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco-aggregate/${jacoco.report.name}</sonar.coverage.jacoco.xmlReportPaths>
        <sonar.javascript.lcov.reportPaths>target/coverage/lcov/lcov.info</sonar.javascript.lcov.reportPaths>
        <sonar.sources>src/main/java,src/main/frontend</sonar.sources>
        <test-coverage.skip-copy-integration-test-report>false</test-coverage.skip-copy-integration-test-report>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-soy</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</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>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <enableQuickReload>true</enableQuickReload>

                    <!-- 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>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                        <Import-Package>com.atlassian.confluence.plugin.descriptor.web.conditions,
                            com.atlassian.confluence.plugin.descriptor.web.urlreadingconditions,
                            com.atlassian.confluence.setup.settings,
                            com.atlassian.confluence.setup,
                            *</Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </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>
            </plugin>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <configuration>
                    <!-- Enable this to get build-time logging of annotations atlassian-spring-scanner-maven-plugin has noticed -->
                    <verbose>false</verbose>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <!-- process-classes seems to be skipped if you are using scala
                             so perhaps use prepare-package -->
                        <phase>process-classes</phase>
                    </execution>
                </executions>
            </plugin>

            <!-- frontend build -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>frontend-install</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <skip>${npm.ci.skip}</skip>
                            <workingDirectory>${project.basedir}</workingDirectory>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>install</argument>
                                <argument>--no-audit</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>frontend-build-production</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <skip>${frontend.build.skip}</skip>
                            <workingDirectory>${project.basedir}</workingDirectory>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>${npm.build.script}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>frontend-checks</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <skip>${npm.test.skip}</skip>
                            <workingDirectory>${project.basedir}</workingDirectory>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>checks</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>frontend-watch-mode</id>
            <activation>
                <property>
                    <name>frontend.watch.mode</name>
                </property>
            </activation>
            <properties>
                <npm.build.script>watch:build-watch-prepare</npm.build.script>
            </properties>
        </profile>
        <profile>
            <id>sonar-ut</id>
            <properties>
                <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco/${jacoco.report.name}</sonar.coverage.jacoco.xmlReportPaths>
            </properties>
        </profile>
        <profile>
            <id>sonar-it</id>
            <properties>
                <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco-it/${jacoco.report.name}</sonar.coverage.jacoco.xmlReportPaths>
                <sonar.javascript.lcov.reportPaths />
            </properties>
        </profile>
    </profiles>
</project>
