<?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>

    <groupId>io.github.pmckeown</groupId>
    <artifactId>dependency-track-maven-plugin</artifactId>
    <version>1.10.2</version>
    <packaging>maven-plugin</packaging>

    <name>Dependency Track Maven Plugin</name>
    <description>Maven plugin to integrate with a Dependency Track server to submit dependency manifests and gather project metrics. Can be used within build pipelines to analyse the current project and optionally fail the build if vulnerabilities are found.</description>
    <url>https://github.com/pmckeown/dependency-track-maven-plugin</url>
    <inceptionYear>2019</inceptionYear>

    <licenses>
        <license>
            <name>Apache-2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Paul McKeown</name>
            <roles>
                <role>Developer</role>
            </roles>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com:pmckeown/dependency-track-maven-plugin.git</connection>
        <developerConnection>scm:git:git@github.com:pmckeown/dependency-track-maven-plugin.git</developerConnection>
        <tag>HEAD</tag>
        <url>https://github.com/pmckeown/dependency-track-maven-plugin.git</url>
    </scm>

    <issueManagement>
        <system>github</system>
        <url>https://github.com/pmckeown/dependency-track-maven-plugin/issues</url>
    </issueManagement>

    <ciManagement>
        <system>github-actions</system>
        <url>https://github.com/pmckeown/dependency-track-maven-plugin/actions/workflows/maven.yml</url>
    </ciManagement>

    <distributionManagement>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- Compile target -->
        <java.version>8</java.version>
        <maven.version>3.9.5</maven.version>
        <!-- Version required to build the project -->
        <java.build.version>11</java.build.version>
        <sonar.organization>pmckeown</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <cyclonedx-maven-plugin.version>2.7.10</cyclonedx-maven-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.konghq</groupId>
            <artifactId>unirest-java</artifactId>
            <version>3.14.5</version>
            <classifier>standalone</classifier>
        </dependency>
        <dependency>
            <groupId>com.konghq</groupId>
            <artifactId>unirest-objectmapper-jackson</artifactId>
            <version>3.14.5</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.17.2</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.17.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>5.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.sisu</groupId>
            <artifactId>org.eclipse.sisu.inject</artifactId>
            <version>0.3.5</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>32.1.1-jre</version>
        </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</groupId>
            <artifactId>maven-core</artifactId>
            <version>${maven.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact</artifactId>
            <version>${maven.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.evanlennick</groupId>
            <artifactId>retry4j</artifactId>
            <version>0.15.0</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.4.0-b180830.0359</version>
        </dependency>
        <dependency>
            <groupId>com.sun.activation</groupId>
            <artifactId>javax.activation</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.3.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <groupId>org.cyclonedx</groupId>
            <artifactId>cyclonedx-core-java</artifactId>
            <version>9.0.4</version>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-compat</artifactId>
            <version>${maven.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>3.15.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-testing</groupId>
            <artifactId>maven-plugin-testing-harness</artifactId>
            <version>3.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock</artifactId>
            <version>3.0.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.14.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.4.0</version>
                </plugin>
                <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_maven-plugin_packaging -->
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.13.0</version>
                    <configuration>
                        <release>${java.version}</release>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-plugin-plugin</artifactId>
                    <version>3.15.1</version>
                    <configuration>
                        <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.5.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.4.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.1.3</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.3</version>
                </plugin>
                <plugin>
                    <artifactId>maven-invoker-plugin</artifactId>
                    <version>3.8.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.11.2</version>
                </plugin>
                <plugin>
                    <groupId>org.sonarsource.scanner.maven</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>5.0.0.4389</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.12</version>
                    <configuration>
                        <append>true</append>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.6.1</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>${maven.version}</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>${java.build.version}</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>prepare-agent-integration</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-site</id>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <outputDirectory>${basedir}/target/classes/META-INF</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>2.45.0</version>
                <configuration>
                    <java>
                        <palantirJavaFormat/>
                        <removeUnusedImports/>
                    </java>
                    <pom>
                        <includes>
                            <include>pom.xml</include>
                            <include>src/it/*/pom.xml</include>
                        </includes>
                        <sortPom>
                            <nrOfIndentSpace>4</nrOfIndentSpace>
                            <indentAttribute>schemaLocation</indentAttribute>
                        </sortPom>
                    </pom>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-plugin-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>mojo-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-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <phase>verify</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- https://central.sonatype.org/publish/publish-portal-maven/ -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.6.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.eclipse.sisu</groupId>
                        <artifactId>sisu-maven-plugin</artifactId>
                        <version>0.3.5</version>
                        <executions>
                            <execution>
                                <id>generate-index</id>
                                <goals>
                                    <goal>index</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
            This profile activates integration with the Sonarcloud project for static analysis of the codebase.
            It is only enabled if the SONAR_TOKEN environment variable is set in the build environment.
        -->
        <profile>
            <id>sonar</id>
            <activation>
                <property>
                    <name>env.SONAR_TOKEN</name>
                </property>
            </activation>
            <properties>
                <sonar.projectKey>io.github.pmckeown:dependency-track-maven-plugin</sonar.projectKey>
                <!--suppress UnresolvedMavenProperty -->
                <sonar.login>${env.SONAR_TOKEN}</sonar.login>
                <sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonarsource.scanner.maven</groupId>
                        <artifactId>sonar-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>sonar</goal>
                                </goals>
                                <phase>verify</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
            The following profile executes this plugin against an instance of Dependency Track.
            It is behind a profile as you need a running server to communicate with.
            2 properties must be set on the command line or as environment variables.

            Example usage with command args:
            mvn clean verify -Peat-your-own-dog-food -Ddependency-track.dependencyTrackBaseUrl -Ddependency-track.dependencyTrackApiKey

            Example usage with environment variables set (DEPENDENCY_TRACK_BASE_URL & DEPENDENCY_TRACK_API_KEY):
            mvn clean verify -Peat-your-own-dog-food
        -->
        <profile>
            <id>eat-your-own-dog-food</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.cyclonedx</groupId>
                        <artifactId>cyclonedx-maven-plugin</artifactId>
                        <version>${cyclonedx-maven-plugin.version}</version>
                        <configuration>
                            <schemaVersion>1.4</schemaVersion>
                            <includeBomSerialNumber>true</includeBomSerialNumber>
                            <includeCompileScope>true</includeCompileScope>
                            <includeProvidedScope>true</includeProvidedScope>
                            <includeRuntimeScope>true</includeRuntimeScope>
                            <includeSystemScope>true</includeSystemScope>
                            <includeTestScope>false</includeTestScope>
                        </configuration>
                        <executions>
                            <execution>
                                <id>generate-bom</id>
                                <goals>
                                    <goal>makeAggregateBom</goal>
                                </goals>
                                <phase>verify</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.github.pmckeown</groupId>
                        <artifactId>dependency-track-maven-plugin</artifactId>
                        <version>${project.version}</version>
                        <configuration>
                            <!--suppress UnresolvedMavenProperty -->
                            <dependencyTrackBaseUrl>${env.DEPENDENCY_TRACK_BASE_URL}</dependencyTrackBaseUrl>
                            <!--suppress UnresolvedMavenProperty -->
                            <apiKey>${env.DEPENDENCY_TRACK_API_KEY}</apiKey>
                            <failOnError>true</failOnError>
                        </configuration>
                        <executions>
                            <execution>
                                <id>upload-bom</id>
                                <goals>
                                    <goal>upload-bom</goal>
                                </goals>
                                <phase>verify</phase>
                                <configuration>
                                    <updateProjectInfo>true</updateProjectInfo>
                                    <isLatest>true</isLatest>
                                    <projectTags>
                                        <name>dog-food</name>
                                    </projectTags>
                                </configuration>
                            </execution>
                            <execution>
                                <id>fail-if-vulnerabilities-present</id>
                                <goals>
                                    <goal>findings</goal>
                                </goals>
                                <phase>verify</phase>
                                <configuration>
                                    <findingThresholds>
                                        <critical>0</critical>
                                        <high>0</high>
                                        <medium>0</medium>
                                        <low>0</low>
                                    </findingThresholds>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.6.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>timestamp-property</goal>
                                </goals>
                                <phase>validate</phase>
                                <configuration>
                                    <pattern>yyyyMMddHHmmss</pattern>
                                    <name>it.snapshot.timestamp</name>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-invoker-plugin</artifactId>
                        <version>3.9.0</version>
                        <executions>
                            <execution>
                                <id>local-plugin-install</id>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>integration-test</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <goals>
                                        <goal>verify</goal>
                                    </goals>
                                    <skipInvocation>${skipITs}</skipInvocation>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
