<?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.gatekeeper</groupId>
        <artifactId>gatekeeper-plugin-parent</artifactId>
        <version>19.2.30</version>
    </parent>

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

    <name>Inspect Permissions - Gatekeeper</name>
    <description>This plugin helps administrators inspect permissions in Confluence.</description>

    <properties>
        <!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <!-- default frontend build mode as opposed to 'watch' mode -->
        <frontend.default.mode>true</frontend.default.mode>
        <!-- rely on the use of a package-lock.json to know when we have to rebuild -->
        <incrementalbuild.excludes.files>main/javascript/node_modules/**/*</incrementalbuild.excludes.files>
        <!-- frontend build related stuff -->
        <scriptsdir>${project.basedir}/scripts</scriptsdir>
        <skipJacocoReport>false</skipJacocoReport>
        <sonar.javascript.lcov.reportPaths>target/coverage/lcov.info</sonar.javascript.lcov.reportPaths>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.confluence</groupId>
                <artifactId>confluence-plugins-platform-pom</artifactId>
                <version>${confluence.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-csv</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>it.unimi.dsi</groupId>
            <artifactId>fastutil</artifactId>
            <version>8.5.14</version>
        </dependency>
        <!-- provided dependencies-->
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <version>${confluence.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.datatype</groupId>
                    <artifactId>jackson-datatype-joda</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.upm</groupId>
            <artifactId>licensing-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.upm</groupId>
            <artifactId>upm-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-bridge</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.templaterenderer</groupId>
            <artifactId>atlassian-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.atlassian.util.concurrent</groupId>
            <artifactId>atlassian-util-concurrent</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.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.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- EXTERNAL DEPENDENCIES FOR PRODUCTION ADDON -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- test dependencies -->
        <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>com.carrotsearch</groupId>
            <artifactId>junit-benchmarks</artifactId>
            <version>0.7.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <version>1.21</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-generator-annprocess</artifactId>
            <version>1.21</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>nl.jqno.equalsverifier</groupId>
            <artifactId>equalsverifier</artifactId>
            <version>3.12.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.cache</groupId>
            <artifactId>atlassian-cache-memory</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- END OF EXTERNAL DEPENDENCIES FOR PRODUCTION ADDON -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.oshi</groupId>
            <artifactId>oshi-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.fugue</groupId>
            <artifactId>fugue</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.supercsv</groupId>
            <artifactId>super-csv</artifactId>
            <version>2.1.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.version}</productDataVersion>
                    <enableQuickReload>${atlassian.dev.mode}</enableQuickReload>
                    <enablePde>false</enablePde>
                    <extractDependencies>false</extractDependencies>
                    <!-- test dependencies are not required in the test jar -->
                    <excludeAllTestDependencies>true</excludeAllTestDependencies>
                    <buildTestPlugin>false</buildTestPlugin>
                    <allowGoogleTracking>false</allowGoogleTracking>
                    <enableDevToolbox>false</enableDevToolbox>
                    <forceUpdateCheck>false</forceUpdateCheck>
                    <containerId>${tomcat.containerId}</containerId>
                    <jvmArgs>${jvmArgs}</jvmArgs>
                    <server>${confluence.hostname}</server>
                    <systemPropertyVariables>
                        <!--set devmode false here to prevent amps from setting it to true by default-->
                        <atlassian.dev.mode>${atlassian.dev.mode}</atlassian.dev.mode>
                        <confluence.index.manager.lock.timeout>5</confluence.index.manager.lock.timeout>
                        <confluence.upgrade.recovery.file.enabled>false</confluence.upgrade.recovery.file.enabled>
                        <atlassian.webresource.disable.minification>${atlassian.dev.mode}</atlassian.webresource.disable.minification>
                        <plugin.webresource.javascript.try.catch.wrapping>${atlassian.dev.mode}</plugin.webresource.javascript.try.catch.wrapping>
                        <plugin.webresource.batch.content.tracking>${atlassian.dev.mode}</plugin.webresource.batch.content.tracking>
                        <upm.pac.disable>true</upm.pac.disable>
                        <upm.plugin.requests.disable>true</upm.plugin.requests.disable>
                        <upm.auto.update.enable>false</upm.auto.update.enable>
                        <index.queue.thread.count>1</index.queue.thread.count>
                        <!-- we can skip preparing the env in tests -->
                        <gatekeeper.is.environment.prepared>false</gatekeeper.is.environment.prepared>
                        <!-- allow hot reloading of npm compiled resources -->
                        <plugin.resource.directories>${project.basedir}/src/main/resources,${project.build.outputDirectory}</plugin.resource.directories>
                    </systemPropertyVariables>
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                        <Spring-Context>*</Spring-Context>
                        <Export-Package />
                        <Import-Package>com.atlassian.confluence.plugin.descriptor.web.conditions,
                            com.atlassian.confluence.plugin.descriptor.web.urlreadingconditions,
                            com.atlassian.extras.api,
                            *</Import-Package>
                    </instructions>
                    <skipVerifyFeManifestAssociations>true</skipVerifyFeManifestAssociations>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <configuration>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.atlassian.lesscss</groupId>
                <artifactId>lesscss-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>compile-less</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <phase>process-resources</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>frontend-build-production</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <skip>${frontend.watch.mode}</skip>
                            <workingDirectory>${project.basedir}/src/main/javascript</workingDirectory>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>install-build</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Development watch mode -->
                        <id>frontend-install</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <workingDirectory>${project.basedir}/src/main/javascript</workingDirectory>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>install</argument>
                                <argument>--no-save</argument>
                                <argument>--no-audit</argument>
                                <argument>--prefer-offline</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Development watch mode -->
                        <id>frontend-build-watch</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <skip>${frontend.default.mode}</skip>
                            <workingDirectory>${project.basedir}/src/main/javascript</workingDirectory>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>watch:build-watch-prepare</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>frontend-checks</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <workingDirectory>${project.basedir}/src/main/javascript</workingDirectory>
                            <executable>${npm.cmd}</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>license-check</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <trimStackTrace>false</trimStackTrace>
                    <!-- various JPMS hacks to make PowerMock work on Java 17 -->
                    <argLine>--add-opens java.base/java.lang=ALL-UNNAMED
                        --add-opens java.base/java.util=ALL-UNNAMED
                        --add-opens java.base/java.util.regex=ALL-UNNAMED
                        --add-opens java.base/java.io=ALL-UNNAMED</argLine>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>disable.frontend.default.mode</id>
            <activation>
                <property>
                    <name>frontend.watch.mode</name>
                </property>
            </activation>
            <properties>
                <frontend.default.mode>false</frontend.default.mode>
            </properties>
        </profile>
        <profile>
            <id>sonar-ut</id>
            <properties>
                <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco-unit/${jacoco.report.name}</sonar.coverage.jacoco.xmlReportPaths>
                <sonar.javascript.lcov.reportPaths>target/coverage/lcov.info</sonar.javascript.lcov.reportPaths>
            </properties>
        </profile>
        <profile>
            <id>sonar-it</id>
            <properties>
                <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco-integration/${jacoco.report.name}</sonar.coverage.jacoco.xmlReportPaths>
                <sonar.javascript.lcov.reportPaths />
            </properties>
        </profile>
    </profiles>
</project>
