<?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.platform.pom</groupId>
        <artifactId>platform-defaults-public</artifactId>
        <version>9.0.0-m015</version>
    </parent>
    <version>6.0.0</version>
    <groupId>com.atlassian.plugins</groupId>
    <artifactId>atlassian-clientside-extensions-parent</artifactId>
    <name>Atlassian Plugins - Client-side Extensions - Parent</name>
    <packaging>pom</packaging>
    <licenses>
        <license>
            <name>BSD License</name>
            <url>https://opensource.org/licenses/BSD-3-Clause</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <scm>
        <connection>scm:git:git@bitbucket.org:atlassian/dc-platform.git</connection>
        <developerConnection>scm:git:git@bitbucket.org:atlassian/dc-platform.git</developerConnection>
        <url>https://bitbucket.org/atlassian/dc-platform</url>
        <tag>atlassian-clientside-extensions-parent-6.0.0</tag>
    </scm>
    <modules>
        <module>atlassian-clientside-extensions-runtime</module>
        <module>atlassian-clientside-extensions-page-bootstrapper</module>
        <module>environments/refapp</module>
        <!-- last module so that it can aggregate jacoco reports and push them to Sonar -->
        <module>atlassian-clientside-extensions-sonar</module>
    </modules>
    <properties>
        <maven.compiler.release>25</maven.compiler.release>
        <!-- the minimum supported versions of the plugin system modules -->
        <atlassian.ozymandias.version>1.0.0</atlassian.ozymandias.version>
        <platform.version>9.0.0-m024</platform.version>
        <!-- the product versions we test in -->
        <refapp.version>${platform.version}</refapp.version>
        <!-- the build tools we use -->
        <amps.version>9.12.6</amps.version>
        <!-- TODO migrate to osgi-javaconfig -->
        <atlassian.spring.scanner.version>2.2.6</atlassian.spring.scanner.version>
        <frontend.maven.plugin.version>1.15.10-atlassian-2</frontend.maven.plugin.version>
        <!-- if true, skip running Yarn install during build (intended to be overridden via the command line) -->
        <skipYarnInstall>false</skipYarnInstall>
        <!-- Sonar multi-module configuration -->
        <jacoco.report>coverage/jacoco</jacoco.report>
        <jacoco.report.file>${jacoco.report}/jacoco.xml</jacoco.report.file>
        <jest.report>coverage/jest</jest.report>
        <jest.report.file>${jest.report}/lcov.info</jest.report.file>
        <eslint.report.paths>coverage/eslint/report.json</eslint.report.paths>
        <sonar.testExecutionReportPaths>${jest.report}/sonar-report.xml</sonar.testExecutionReportPaths>
        <gpg.keyname>${env.GPG_KEY_NAME}</gpg.keyname>
        <gpg.passphrase>${env.GPG_PASS_PHRASE}</gpg.passphrase>
        <mockito.version>5.23.0</mockito.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <!-- Platform POMs -->
            <dependency>
                <groupId>com.atlassian.platform.dependencies</groupId>
                <artifactId>platform-public-api</artifactId>
                <version>${platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.atlassian.platform.dependencies</groupId>
                <artifactId>platform-deprecated-public-api</artifactId>
                <version>${platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.atlassian.platform.dependencies</groupId>
                <artifactId>platform-internal-api</artifactId>
                <version>${platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.atlassian.platform.dependencies</groupId>
                <artifactId>platform-test-resources</artifactId>
                <version>${platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- Project modules -->
            <dependency>
                <groupId>com.atlassian.plugins</groupId>
                <artifactId>atlassian-clientside-extensions-page-bootstrapper</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.atlassian.plugins</groupId>
                <artifactId>atlassian-clientside-extensions-runtime</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.atlassian.plugins</groupId>
                <artifactId>atlassian-clientside-extensions-demo</artifactId>
                <version>${project.version}</version>
            </dependency>
            <!-- Third party -->
            <!-- TODO rely on Platform, once it will properly define OSGi dependency -->
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>osgi.core</artifactId>
                <version>8.0.0</version>
            </dependency>
            <!-- test dependencies -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.13.2</version>
            </dependency>
            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-library</artifactId>
                <version>1.3</version>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>${mockito.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <profiles>
        <profile>
            <id>build-mode-is-set-by-node-env</id>
            <activation>
                <property>
                    <name>env.NODE_ENV</name>
                </property>
            </activation>
            <properties>
                <frontend.build.mode>${env.NODE_ENV}</frontend.build.mode>
            </properties>
        </profile>
        <profile>
            <id>build-mode-is-production-by-default</id>
            <activation>
                <property>
                    <name>!env.NODE_ENV</name>
                </property>
            </activation>
            <properties>
                <frontend.build.mode>production</frontend.build.mode>
            </properties>
        </profile>
        <profile>
            <id>test</id>
            <activation>
                <property>
                    <name>!report</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>step-4-run-frontend-unit-tests</id>
                                <goals>
                                    <goal>corepack</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipTests}</skip>
                                    <arguments>yarn test:packages</arguments>
                                    <workingDirectory>${project.basedir}</workingDirectory>
                                    <environmentVariables>
                                        <NODE_ENV>development</NODE_ENV>
                                    </environmentVariables>
                                </configuration>
                                <phase>test</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>test-and-lint-with-report</id>
            <activation>
                <property>
                    <name>report</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>step-4-run-frontend-unit-tests-report</id>
                                <goals>
                                    <goal>corepack</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipTests}</skip>
                                    <arguments>yarn test:ci</arguments>
                                    <workingDirectory>${project.basedir}</workingDirectory>
                                    <environmentVariables>
                                        <NODE_ENV>development</NODE_ENV>
                                    </environmentVariables>
                                </configuration>
                                <phase>test</phase>
                            </execution>
                            <execution>
                                <id>step-5-generate-frontend-lint-report</id>
                                <goals>
                                    <goal>corepack</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipTests}</skip>
                                    <arguments>yarn lint:eslint:report</arguments>
                                    <workingDirectory>${project.basedir}</workingDirectory>
                                    <environmentVariables>
                                        <NODE_ENV>development</NODE_ENV>
                                    </environmentVariables>
                                </configuration>
                                <phase>test</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId>
                    <version>${frontend.maven.plugin.version}</version>
                    <configuration>
                        <installDirectory>${project.build.outputDirectory}</installDirectory>
                        <workingDirectory>${project.basedir}</workingDirectory>
                        <npmInheritsProxyConfigFromMaven>true</npmInheritsProxyConfigFromMaven>
                        <environmentVariables>
                            <NODE_ENV>${frontend.build.mode}</NODE_ENV>
                        </environmentVariables>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.sonarsource.scanner.maven</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>3.9.1.2184</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.14</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>step-1-set-up-environment</id>
                        <goals>
                            <goal>install-node-and-corepack</goal>
                        </goals>
                        <configuration>
                            <workingDirectory>${project.basedir}</workingDirectory>
                        </configuration>
                        <phase>initialize</phase>
                    </execution>
                    <execution>
                        <id>step-2-install-frontend-dependencies</id>
                        <goals>
                            <goal>corepack</goal>
                        </goals>
                        <configuration>
                            <skip>${skipYarnInstall}</skip>
                            <workingDirectory>${project.basedir}</workingDirectory>
                            <arguments>yarn install --frozen-lockfile --ignore-optional --mutex=network</arguments>
                            <environmentVariables>
                                <!-- Must always be development so that we get our dev dependencies -->
                                <NODE_ENV>development</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                        <phase>initialize</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <java>
                        <palantirJavaFormat>
                            <version>2.89.0</version>
                        </palantirJavaFormat>
                        <importOrder>
                            <wildcardsLast>true</wildcardsLast>
                            <order>java|javax|jakarta,lombok,org.spring|org|com|io,,com.atlassian,com.atlassian.beacon|\#,\#com.atlassian</order>
                        </importOrder>
                        <removeUnusedImports />
                    </java>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>com.atlassian.maven.enforcer</groupId>
                        <artifactId>maven-enforcer-rules</artifactId>
                        <version>1.5.20</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>ban-milestones-and-release-candidates</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <banVersionDeps>
                                    <ignoreProvided>true</ignoreProvided>
                                </banVersionDeps>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
