<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>

<name>Cryostat Agent</name>
<description>JVM Agent for Cryostat</description>
<url>https://github.com/cryostatio/cryostat-agent</url>
<inceptionYear>2022</inceptionYear>
<packaging>jar</packaging>

<groupId>io.cryostat</groupId>
<artifactId>cryostat-agent</artifactId>

<version>0.5.2</version>

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

<developers>
  <developer>
    <name>Andrew Azores</name>
    <email>aazores@redhat.com</email>
    <organization>Red Hat</organization>
    <organizationUrl>https://www.redhat.com</organizationUrl>
  </developer>
  <developer>
    <name>Elliott Baron</name>
    <email>ebaron@redhat.com</email>
    <organization>Red Hat</organization>
    <organizationUrl>https://www.redhat.com</organizationUrl>
  </developer>
</developers>

<distributionManagement>
  <repository>
    <id>github</id>
    <name>GitHub Packages</name>
    <url>https://maven.pkg.github.com/cryostatio/cryostat-agent</url>
  </repository>
</distributionManagement>

<scm>
  <connection>scm:git://github.com/cryostatio/cryostat-agent.git</connection>
  <developerConnection>scm:git:ssh://github.com:cryostatio/cryostat-agent.git</developerConnection>
  <url>https://github.com/cryostatio/cryostat-agent/tree/main</url>
</scm>

<properties>
  <mainClass>io.cryostat.agent.Agent</mainClass>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <java.version>11</java.version>
  <maven.compiler.target>${java.version}</maven.compiler.target>
  <maven.compiler.source>${java.version}</maven.compiler.source>

  <io.reactiverse.plugin.version>1.0.27</io.reactiverse.plugin.version>
  <org.apache.maven.plugins.jar.version>3.4.2</org.apache.maven.plugins.jar.version>
  <org.apache.maven.plugins.shade.version>3.6.0</org.apache.maven.plugins.shade.version>
  <org.apache.maven.plugins.compiler.version>3.13.0</org.apache.maven.plugins.compiler.version>
  <org.apache.maven.plugins.surefire.version>2.22.2</org.apache.maven.plugins.surefire.version>
  <org.apache.maven.plugins.failsafe.version>${org.apache.maven.plugins.surefire.version}</org.apache.maven.plugins.failsafe.version>
  <org.apache.maven.plugins.site.version>3.21.0</org.apache.maven.plugins.site.version>
  <org.apache.maven.plugins.info.reports.version>3.8.0</org.apache.maven.plugins.info.reports.version>
  <org.apache.maven.plugins.clean.version>3.2.0</org.apache.maven.plugins.clean.version>
  <org.apache.maven.plugins.resources.version>3.3.0</org.apache.maven.plugins.resources.version>
  <org.apache.maven.plugins.assembly.version>3.4.2</org.apache.maven.plugins.assembly.version>
  <com.mycila.license.maven.plugin.version>4.6</com.mycila.license.maven.plugin.version>
  <org.owasp.dependency.check.version>12.0.1</org.owasp.dependency.check.version>

  <!-- Use a separate property for dependency alignment purposes. -->
  <com.google.dagger.version>2.55</com.google.dagger.version>
  <com.google.dagger.compiler.version>${com.google.dagger.version}</com.google.dagger.compiler.version>

  <io.cryostat.libcryostat.version>4.0.2</io.cryostat.libcryostat.version>

  <org.apache.commons.lang3.version>3.17.0</org.apache.commons.lang3.version>
  <org.apache.commons.io.version>2.19.0</org.apache.commons.io.version>
  <org.apache.httpcomponents.httpclient.version>4.5.14</org.apache.httpcomponents.httpclient.version>
  <org.apache.httpcomponents.httpmime.version>${org.apache.httpcomponents.httpclient.version}</org.apache.httpcomponents.httpmime.version>
  <com.fasterxml.jackson.version>2.18.0</com.fasterxml.jackson.version>
  <io.smallrye.config.version>3.9.1</io.smallrye.config.version>
  <org.slf4j.version>2.0.16</org.slf4j.version>
  <org.projectnessie.cel.bom.version>0.4.5</org.projectnessie.cel.bom.version>
  <com.google.protobuf-java.version>3.25.5</com.google.protobuf-java.version>
  <info.picocli.version>4.7.6</info.picocli.version>
  <com.redhat.insights.agent.version>1.0.3</com.redhat.insights.agent.version>

  <com.github.spotbugs.version>4.9.0</com.github.spotbugs.version>
  <com.github.spotbugs.plugin.version>4.8.6.6</com.github.spotbugs.plugin.version>
  <org.junit.jupiter.version>5.11.4</org.junit.jupiter.version>
  <org.hamcrest.version>3.0</org.hamcrest.version>
  <org.mockito.version>5.15.2</org.mockito.version>
  <org.jacoco.maven.plugin.version>0.8.12</org.jacoco.maven.plugin.version>
  <com.diffplug.spotless.maven.plugin.version>2.44.2</com.diffplug.spotless.maven.plugin.version>
  <com.google.googlejavaformat.version>1.17.0</com.google.googlejavaformat.version>
  <org.jsoup.version>1.15.3</org.jsoup.version>

  <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
  <maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
  <jreleaser-maven-plugin.version>1.19.0</jreleaser-maven-plugin.version>
  <org.codehaus.mojo.exec.plugin.version>3.5.0</org.codehaus.mojo.exec.plugin.version>

  <shade.prefix>io.cryostat.agent.shaded</shade.prefix>

  <cryostat.server.version.min>4.0.0</cryostat.server.version.min>
  <cryostat.server.version.max>5.0.0</cryostat.server.version.max>
</properties>

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.smallrye.config</groupId>
      <artifactId>smallrye-config-parent</artifactId>
      <version>${io.smallrye.config.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson</groupId>
      <artifactId>jackson-bom</artifactId>
      <version>${com.fasterxml.jackson.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    <dependency>
      <groupId>org.projectnessie.cel</groupId>
      <artifactId>cel-bom</artifactId>
      <version>${org.projectnessie.cel.bom.version}</version>
      <type>pom</type>
      <scope>import</scope>
      <exclusions>
        <exclusion>
          <groupId>com.google.protobuf</groupId>
          <artifactId>protobuf-java</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
</dependencyManagement>
<dependencies>
  <dependency>
    <groupId>com.google.dagger</groupId>
    <artifactId>dagger</artifactId>
    <version>${com.google.dagger.version}</version>
    <scope>compile</scope>
  </dependency>
  <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>${org.slf4j.version}</version>
    <scope>compile</scope>
    <optional>true</optional>
  </dependency>
  <!-- TODO remove this SLF4J provider. We should just depend on what SLF4J provider is available in the attached
        application's classpath at runtime, if any. -->
  <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>${org.slf4j.version}</version>
  </dependency>
  <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>${org.slf4j.version}</version>
    <scope>runtime</scope>
    <optional>true</optional>
  </dependency>
  <dependency>
    <groupId>io.cryostat</groupId>
    <artifactId>libcryostat</artifactId>
    <version>${io.cryostat.libcryostat.version}</version>
    <exclusions>
      <exclusion>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>info.picocli</groupId>
    <artifactId>picocli</artifactId>
    <version>${info.picocli.version}</version>
  </dependency>
  <dependency>
    <groupId>org.projectnessie.cel</groupId>
    <artifactId>cel-tools</artifactId>
  </dependency>
  <!-- FIXME this is a forced version override of the protobuf required by projectnessie -->
  <dependency>
    <groupId>com.google.protobuf</groupId>
    <artifactId>protobuf-java</artifactId>
    <version>${com.google.protobuf-java.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>${org.apache.commons.lang3.version}</version>
  </dependency>
  <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>${org.apache.commons.io.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>${org.apache.httpcomponents.httpclient.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpmime</artifactId>
    <version>${org.apache.httpcomponents.httpmime.version}</version>
  </dependency>
  <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
  </dependency>
  <dependency>
    <groupId>org.eclipse.microprofile.config</groupId>
    <artifactId>microprofile-config-api</artifactId>
    <scope>compile</scope>
  </dependency>
  <dependency>
    <groupId>io.smallrye.config</groupId>
    <artifactId>smallrye-config</artifactId>
    <version>${io.smallrye.config.version}</version>
    <scope>runtime</scope>
  </dependency>
  <dependency>
    <groupId>com.redhat.insights</groupId>
    <artifactId>runtimes-agent</artifactId>
    <version>${com.redhat.insights.agent.version}</version>
    <classifier>shaded</classifier>
    <exclusions>
      <exclusion>
        <groupId>jdk.tools</groupId>
        <artifactId>jdk.tools</artifactId>
      </exclusion>
    </exclusions>
  </dependency>

  <!-- test deps -->
  <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>${org.junit.jupiter.version}</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest</artifactId>
    <version>${org.hamcrest.version}</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-junit-jupiter</artifactId>
    <version>${org.mockito.version}</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>${org.mockito.version}</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>com.github.spotbugs</groupId>
    <artifactId>spotbugs-annotations</artifactId>
    <version>${com.github.spotbugs.version}</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

<build>
  <resources>
    <resource>
      <directory>src/main/resources</directory>
      <filtering>true</filtering>
    </resource>
  </resources>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>${org.apache.maven.plugins.jar.version}</version>
      <configuration>
        <archive>
          <manifest>
            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            <mainClass>${mainClass}</mainClass>
          </manifest>
          <manifestEntries>
            <Premain-Class>${mainClass}</Premain-Class>
            <Agent-Class>${mainClass}</Agent-Class>
          </manifestEntries>
        </archive>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>${org.codehaus.mojo.exec.plugin.version}</version>
      <executions>
        <execution>
          <id>generate-git-version</id>
          <phase>generate-resources</phase>
          <goals>
            <goal>exec</goal>
          </goals>
          <configuration>
            <executable>git</executable>
            <arguments>
              <argument>rev-parse</argument>
              <argument>--verify</argument>
              <argument>HEAD</argument>
            </arguments>
            <outputFile>${project.build.directory}/classes/META-INF/gitinfo</outputFile>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>${org.apache.maven.plugins.shade.version}</version>
      <configuration></configuration>
      <executions>
        <execution>
          <id>shade-jar-with-dependencies</id>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
          <configuration>
            <createDependencyReducedPom>false</createDependencyReducedPom>
            <useDependencyReducedPomInJar>false</useDependencyReducedPomInJar>
            <createSourcesJar>true</createSourcesJar>
            <shadedArtifactAttached>true</shadedArtifactAttached>
            <shadedClassifierName>shaded</shadedClassifierName>
            <relocations>
              <relocation>
                <pattern>io.cryostat.libcryostat</pattern>
                <shadedPattern>${shade.prefix}.io.cryostat.libcryostat</shadedPattern>
              </relocation>
              <relocation>
                <pattern>io.cryostat.core</pattern>
                <shadedPattern>${shade.prefix}.io.cryostat.core</shadedPattern>
              </relocation>
              <relocation>
                <pattern>org.projectnessie</pattern>
                <shadedPattern>${shade.prefix}.org.projectnessie</shadedPattern>
              </relocation>
              <relocation>
                <pattern>org.apache</pattern>
                <shadedPattern>${shade.prefix}.org.apache.shaded</shadedPattern>
              </relocation>
              <relocation>
                <pattern>org.slf4j</pattern>
                <shadedPattern>${shade.prefix}.org.slf4j</shadedPattern>
              </relocation>
              <relocation>
                <pattern>java.util.logging.Logger</pattern>
                <shadedPattern>${shade.prefix}.ShadeLogger</shadedPattern>
                <excludes>
                  <exclude>${shade.prefix}.ShadeLogger</exclude>
                </excludes>
              </relocation>
              <relocation>
                <pattern>io.smallrye.config</pattern>
                <shadedPattern>${shade.prefix}.io.smallrye.config</shadedPattern>
              </relocation>
              <relocation>
                <pattern>org.eclipse.microprofile</pattern>
                <shadedPattern>${shade.prefix}.org.eclipse.microprofile</shadedPattern>
              </relocation>
              <relocation>
                <pattern>org.jboss</pattern>
                <shadedPattern>${shade.prefix}.org.jboss</shadedPattern>
              </relocation>
              <relocation>
                <pattern>javax.annotations</pattern>
                <shadedPattern>${shade.prefix}.javax.annotations</shadedPattern>
              </relocation>
              <relocation>
                <pattern>com.fasterxml.jackson</pattern>
                <shadedPattern>${shade.prefix}.com.fasterxml.jackson</shadedPattern>
              </relocation>
              <relocation>
                <pattern>picocli</pattern>
                <shadedPattern>${shade.prefix}.picocli</shadedPattern>
              </relocation>
            </relocations>
            <transformers>
              <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
              <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
              <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
              <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
                  <addHeader>false</addHeader>
              </transformer>
            </transformers>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>${org.apache.maven.plugins.compiler.version}</version>
      <configuration>
        <forceJavacCompilerUse>true</forceJavacCompilerUse>
        <showDeprecation>true</showDeprecation>
        <showWarnings>true</showWarnings>
        <annotationProcessorPaths>
          <path>
            <groupId>com.google.dagger</groupId>
            <artifactId>dagger-compiler</artifactId>
            <version>${com.google.dagger.compiler.version}</version>
          </path>
        </annotationProcessorPaths>
      </configuration>
    </plugin>
    <plugin>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-maven-plugin</artifactId>
      <version>${com.github.spotbugs.plugin.version}</version>
      <executions>
        <execution>
          <id>spotbugs</id>
          <phase>verify</phase>
          <goals>
            <goal>check</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.jacoco</groupId>
      <artifactId>jacoco-maven-plugin</artifactId>
      <version>${org.jacoco.maven.plugin.version}</version>
      <executions>
        <execution>
          <goals>
            <goal>prepare-agent</goal>
          </goals>
        </execution>
        <execution>
          <id>report</id>
          <phase>verify</phase>
          <goals>
            <goal>report</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>com.diffplug.spotless</groupId>
      <artifactId>spotless-maven-plugin</artifactId>
      <version>${com.diffplug.spotless.maven.plugin.version}</version>
      <executions>
        <execution>
          <id>spotless</id>
          <phase>verify</phase>
          <goals>
            <goal>check</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <java>
          <googleJavaFormat>
            <version>${com.google.googlejavaformat.version}</version>
            <style>AOSP</style>
            <reflowLongStrings>true</reflowLongStrings>
          </googleJavaFormat>
          <trimTrailingWhitespace/>
          <endWithNewline/>
          <importOrder>
            <order>java,javax,io.cryostat,</order>
          </importOrder>
          <removeUnusedImports/>
        </java>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-site-plugin</artifactId>
      <version>${org.apache.maven.plugins.site.version}</version>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-project-info-reports-plugin</artifactId>
      <version>${org.apache.maven.plugins.info.reports.version}</version>
    </plugin>
    <plugin>
      <groupId>com.mycila</groupId>
      <artifactId>license-maven-plugin</artifactId>
      <version>${com.mycila.license.maven.plugin.version}</version>
      <configuration>
        <licenseSets>
          <licenseSet>
            <header>LICENSE</header>
            <includes>
              <include>src/main/**/*.java</include>
              <include>src/test/**/*.java</include>
            </includes>
          </licenseSet>
        </licenseSets>
      </configuration>
      <executions>
        <execution>
          <id>update-license</id>
          <goals>
            <goal>check</goal>
          </goals>
          <phase>process-sources</phase>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

<reporting>
  <plugins>
    <plugin>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-maven-plugin</artifactId>
      <version>${com.github.spotbugs.plugin.version}</version>
    </plugin>
    <plugin>
      <groupId>org.jacoco</groupId>
      <artifactId>jacoco-maven-plugin</artifactId>
      <version>${org.jacoco.maven.plugin.version}</version>
      <configuration>
        <excludes>
          <exclude>**/*_Factory.*</exclude>
          <exclude>**/*_Provide*Factory.*</exclude>
          <exclude>**/Dagger*.*</exclude>
          <exclude>**/*Module_*Factory.*</exclude>
          <exclude>**/*Module.*</exclude>
        </excludes>
      </configuration>
      <reportSets>
        <reportSet>
          <reports>
            <report>report</report>
          </reports>
        </reportSet>
      </reportSets>
    </plugin>
  </plugins>
</reporting>

<profiles>
  <profile>
    <id>dep-check</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.owasp</groupId>
          <artifactId>dependency-check-maven</artifactId>
          <version>${org.owasp.dependency.check.version}</version>
          <configuration>
            <failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
          </configuration>
          <executions>
            <execution>
              <id>check-for-vulnerable-deps</id>
              <goals>
                <goal>check</goal>
              </goals>
              <phase>validate</phase>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>

  <profile>
    <id>release</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.jreleaser</groupId>
          <artifactId>jreleaser-maven-plugin</artifactId>
          <version>${jreleaser-maven-plugin.version}</version>
          <inherited>false</inherited>
          <configuration>
            <jreleaser>
              <signing>
                <active>ALWAYS</active>
                <armored>true</armored>
              </signing>
              <deploy>
                <maven>
                  <mavenCentral>
                    <release-deploy>
                      <active>RELEASE</active>
                      <url>https://central.sonatype.com/api/v1/publisher</url>
                      <stagingRepositories>target/staging-deploy</stagingRepositories>
                    </release-deploy>
                  </mavenCentral>
                  <nexus2>
                    <snapshot-deploy>
                      <active>SNAPSHOT</active>
                      <snapshotUrl>https://central.sonatype.com/repository/maven-snapshots/</snapshotUrl>
                      <applyMavenCentralRules>true</applyMavenCentralRules>
                      <snapshotSupported>true</snapshotSupported>
                      <closeRepository>true</closeRepository>
                      <releaseRepository>true</releaseRepository>
                      <stagingRepositories>target/staging-deploy</stagingRepositories>
                    </snapshot-deploy>
                  </nexus2>
                </maven>
              </deploy>
            </jreleaser>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>

  <profile>
    <id>snapshots</id>
    <repositories>
      <repository>
        <id>central.sonatype.com-snapshot</id>
        <url>https://central.sonatype.com/repository/maven-snapshots/</url>
        <releases>
          <enabled>false</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
          <updatePolicy>always</updatePolicy>
        </snapshots>
      </repository>
    </repositories>
  </profile>

  <profile>
    <id>publication</id>
    <properties>
      <altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository>
    </properties>
    <build>
      <defaultGoal>deploy</defaultGoal>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
              <configuration>
                <attach>true</attach>
                <failOnError>false</failOnError>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source-plugin.version}</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <goals>
                <goal>jar-no-fork</goal>
              </goals>
              <configuration>
                <attach>true</attach>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

</project>
