<?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.pom</groupId>
        <artifactId>closedsource-pom</artifactId>
        <!-- Do not bump without upgrading the pre-requisite Maven version (breaking) -->
        <version>5.0.29</version>
    </parent>

    <groupId>com.atlassian.maven.plugins</groupId>
    <artifactId>license-maven-plugin</artifactId>
    <version>3.0.2</version>
    <packaging>maven-plugin</packaging>

    <name>Atlassian License Maven Plugin</name>
    <description>Handles all things license related at Atlassian</description>

    <prerequisites>
        <maven>${maven.version}</maven>
    </prerequisites>

    <scm>
        <connection>scm:git:ssh://git@stash.atlassian.com:7997/cp/atlassian-license-maven-plugin.git</connection>
        <developerConnection>scm:git:ssh://git@stash.atlassian.com:7997/cp/atlassian-license-maven-plugin.git</developerConnection>
        <url>https://stash.atlassian.com/projects/cp/repos/atlassian-license-maven-plugin</url>
        <tag>license-maven-plugin-3.0.2</tag>
    </scm>

    <properties>
        <maven.shared.utils.version>3.3.4</maven.shared.utils.version>
        <maven.version>3.9.9</maven.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <settingsFile>${user.home}/.m2/settings.xml</settingsFile>
        <testOnly />
        <palantirJavaFormat.version>2.85.0</palantirJavaFormat.version>
        <spotless.version>3.2.1</spotless.version>
        <maven.javadoc.skip>true</maven.javadoc.skip>
        <maven.compiler.release>17</maven.compiler.release>
        <jackson.version>2.21.2</jackson.version>
        <mockito.version>5.21.0</mockito.version>
        <slf4j.version>2.0.17</slf4j.version>
    </properties>

    <dependencies>
        <!-- JSON parser for Java SBOM parsing -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>${maven.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.sonatype.plexus</groupId>
                    <artifactId>plexus-cipher</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>${maven.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>3.13.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-dependency-tree</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-invoker</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-compat</artifactId>
            <version>${maven.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-http</artifactId>
            <version>2.12</version>
        </dependency>
        <dependency>
            <groupId>de.schlichtherle.truezip</groupId>
            <artifactId>truezip-driver-zip</artifactId>
            <version>7.7.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcprov-jdk16</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>de.schlichtherle.truezip</groupId>
            <artifactId>truezip-file</artifactId>
            <version>7.7.1</version>
        </dependency>
        <dependency>
            <groupId>com.synopsys.integration</groupId>
            <artifactId>blackduck-common</artifactId>
            <version>65.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.blackducksoftware.bdio</groupId>
                    <artifactId>bdio2</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.synopsys.integration</groupId>
                    <artifactId>phone-home-client</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-compress</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>
            </exclusions>
        </dependency>
        <!-- Because Scala needs all the annotations from truezip to compile -->
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
            <version>1.3.9</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>1.3.9</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <!-- Apache HttpClient for NPM registry access -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>
        <!-- JUnit 5 (Jupiter) for new tests -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.10.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.27.7</version>
            <scope>test</scope>
        </dependency>
        <!-- SLF4J Simple binding for tests -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.jayway.jsonpath</groupId>
                <artifactId>json-path</artifactId>
                <version>2.10.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.maven.shared</groupId>
                <artifactId>maven-shared-utils</artifactId>
                <version>${maven.shared.utils.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jsoup</groupId>
                <artifactId>jsoup</artifactId>
                <version>1.22.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.5.13</version>
            </dependency>
            <dependency>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils</artifactId>
                <version>1.11.0</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.21.0</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.15</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-compress</artifactId>
                <version>1.28.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.20.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-text</artifactId>
                <version>1.15.0</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-invoker-plugin</artifactId>
                    <version>3.9.1</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.groovy</groupId>
                            <artifactId>groovy</artifactId>
                            <version>5.0.2</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                        <settingsFile>${settingsFile}</settingsFile>
                        <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.3</version>
                    <configuration>
                        <arguments>-Dmaven.test.skip</arguments>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
                    <requiredJavaVersion>17</requiredJavaVersion>
                </configuration>
                <executions>
                    <execution>
                        <id>default-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>help-goal</id>
                        <goals>
                            <goal>helpmojo</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <skipTests>false</skipTests>
                    <!-- Include JUnit 5 tests when skipTests is false -->
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*Tests.java</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>${spotless.version}</version>
                <configuration>
                    <java>
                        <palantirJavaFormat>
                            <!-- Optionally specify a version -->
                            <version>${palantirJavaFormat.version}</version>
                        </palantirJavaFormat>
                        <!-- Automatically replace JetBrains annotations with standard javax.annotation -->
                        <replaceRegex>
                            <name>Replace JetBrains NotNull import</name>
                            <searchRegex>import org\.jetbrains\.annotations\.NotNull;</searchRegex>
                            <replacement>import javax.annotation.Nonnull;</replacement>
                        </replaceRegex>
                        <replaceRegex>
                            <name>Replace JetBrains Nullable import</name>
                            <searchRegex>import org\.jetbrains\.annotations\.Nullable;</searchRegex>
                            <replacement>import javax.annotation.Nullable;</replacement>
                        </replaceRegex>
                        <replaceRegex>
                            <name>Replace @NotNull annotation usage</name>
                            <searchRegex>@NotNull\b</searchRegex>
                            <replacement>@Nonnull</replacement>
                        </replaceRegex>
                        <!-- Prevent accidental future use of other JetBrains annotations -->
                        <replaceRegex>
                            <name>Forbid other JetBrains annotations - use javax.annotation instead</name>
                            <searchRegex>import org\.jetbrains\.annotations\.\w+;</searchRegex>
                            <replacement>// ERROR: JetBrains annotations not allowed. Use javax.annotation instead</replacement>
                        </replaceRegex>
                    </java>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>run-all-its</id>
            <activation>
                <property>
                    <name>skipTests</name>
                    <value>!true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-invoker-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-tests</id>
                                <goals>
                                    <goal>install</goal>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <pomIncludes>
                                        <pomInclude>bom/*/pom.xml</pomInclude>
                                        <pomInclude>open-source-distro/*/pom.xml</pomInclude>
                                        <pomInclude>notice/*/pom.xml</pomInclude>
                                        <pomInclude>verify/*/pom.xml</pomInclude>
                                        <pomInclude>download/*/pom.xml</pomInclude>
                                        <pomInclude>seed/*/pom.xml</pomInclude>
                                    </pomIncludes>
                                    <pomExcludes>
                                        <!-- SKIP: Test requires license repo with source-required license entry -->
                                        <pomExclude>verify/verify-nosource/pom.xml</pomExclude>
                                    </pomExcludes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>run-its-with-blackduck-token</id>
            <activation>
                <property>
                    <name>blackduck.api.token</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-invoker-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-tests-with-api-token</id>
                                <goals>
                                    <goal>install</goal>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <showErrors>true</showErrors>
                                    <pomIncludes>
                                        <pomInclude>BD-notice/*/pom.xml</pomInclude>
                                        <pomInclude>BD-update-cache/*/pom.xml</pomInclude>
                                        <pomInclude>BD-verify/*/pom.xml</pomInclude>
                                    </pomIncludes>
                                    <properties>
                                        <blackduck.api.token>${blackduck.api.token}</blackduck.api.token>
                                    </properties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>run-subset-its</id>
            <activation>
                <property>
                    <name>testOnly</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-invoker-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-test-subset</id>
                                <goals>
                                    <goal>install</goal>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <showErrors>true</showErrors>
                                    <pomIncludes>
                                        <pomInclude>${testOnly}/pom.xml</pomInclude>
                                    </pomIncludes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
