<?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>com.redhat.insights</groupId>
  <artifactId>runtimes-java</artifactId>
  <version>2.0.4</version>
  <packaging>pom</packaging>

  <name>Red Hat Insights Java Client</name>
  <description>Red Hat Insights Java Client</description>
  <url>https://github.com/RedHatInsights/insights-java-client</url>
  <inceptionYear>2023</inceptionYear>

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

  <developers>
    <developer>
      <name>Benjamin Evans</name>
      <email>beevans@redhat.com</email>
      <organization>Red Hat</organization>
      <organizationUrl>https://www.redhat.com/</organizationUrl>
    </developer>
    <developer>
      <name>Julien Ponge</name>
      <email>jponge@redhat.com</email>
      <organization>Red Hat</organization>
      <organizationUrl>https://www.redhat.com/</organizationUrl>
    </developer>
    <developer>
      <name>Emmanuel Hugonnet</name>
      <email>ehugonne@redhat.com</email>
      <organization>Red Hat</organization>
      <organizationUrl>https://www.redhat.com/</organizationUrl>
    </developer>
  </developers>

  <modules>
    <module>api</module>
    <module>runtime</module>
    <module>jboss-cert-helper</module>
  </modules>

  <scm>
    <connection>scm:git:git://github.com/RedHatInsights/insights-java-client.git</connection>
    <developerConnection>scm:git:ssh://github.com:RedHatInsights/insights-java-client.git</developerConnection>
    <url>http://github.com/RedHatInsights/insights-java-client/tree/main</url>
  </scm>

  <distributionManagement>
    <repository>
      <id>github</id>
      <name>GitHub RedHatInsights Apache Maven Packages</name>
      <url>https://maven.pkg.github.com/RedHatInsights/insights-java-client</url>
    </repository>
  </distributionManagement>

  <properties>
    <maven.compiler.release>11</maven.compiler.release>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <skip.spotless>false</skip.spotless>

    <!-- Core dependencies versions -->
    <jackson-core.version>2.18.0</jackson-core.version>
    <jackson-databind.version>2.17.2</jackson-databind.version>
    <jackson-datatype-jsr310>2.17.2</jackson-datatype-jsr310>
    <wildfly-elytron.version>2.6.0.Final</wildfly-elytron.version>

    <!-- Test libraries versions -->
    <junit.version>5.10.3</junit.version>
    <mockito.version>5.14.0</mockito.version>
    <servlet-api.version>4.0.1</servlet-api.version>
    <servlet-jsp-api.version>2.3.3</servlet-jsp-api.version>
    <vertx.version>4.5.10</vertx.version>
    <smallrye-mutiny-vertx-bindings.version>3.15.1</smallrye-mutiny-vertx-bindings.version>
    <system-stubs-jupiter.version>2.1.7</system-stubs-jupiter.version>
    <awaitility.version>4.2.1</awaitility.version>

    <!-- Plugins versions -->
    <maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
    <google-java-format.version>1.23.0</google-java-format.version>
    <spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
    <maven-surefire-plugin.version>3.3.1</maven-surefire-plugin.version>
    <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
    <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
    <error-prone.version>2.31.0</error-prone.version>
    <nullaway.version>0.11.3</nullaway.version>
    <jspecify.version>1.0.0</jspecify.version>
    <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
    <maven-install-plugin.version>3.1.2</maven-install-plugin.version>
    <maven-clean-plugin.version>3.4.0</maven-clean-plugin.version>
    <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
    <maven-javadoc-plugin.version>3.8.0</maven-javadoc-plugin.version>
    <maven-deploy-plugin.version>3.1.2</maven-deploy-plugin.version>
    <jreleaser-maven-plugin.version>1.14.0</jreleaser-maven-plugin.version>
  </properties>

  <dependencyManagement>
    <dependencies>

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>runtimes-java-api</artifactId>
        <version>${project.version}</version>
      </dependency>

      <!-- Core dependencies -->
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>${jackson-core.version}</version>
      </dependency>

      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson-databind.version}</version>
      </dependency>

      <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
        <version>${jackson-datatype-jsr310}</version>
      </dependency>

      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>${jackson-datatype-jsr310}</version>
      </dependency>

      <dependency>
        <groupId>org.wildfly.security</groupId>
        <artifactId>wildfly-elytron-x500-cert</artifactId>
        <version>${wildfly-elytron.version}</version>
      </dependency>

      <!-- Null Protection -->
      <dependency>
        <groupId>org.jspecify</groupId>
        <artifactId>jspecify</artifactId>
        <version>${jspecify.version}</version>
      </dependency>

      <!-- Test dependencies -->
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>${junit.version}</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.awaitility</groupId>
        <artifactId>awaitility</artifactId>
        <version>${awaitility.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>${servlet-api.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>${servlet-jsp-api.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>uk.org.webcompere</groupId>
        <artifactId>system-stubs-jupiter</artifactId>
        <version>${system-stubs-jupiter.version}</version>
        <scope>test</scope>
      </dependency>

      <!-- Vert.x for testing -->
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-stack-depchain</artifactId>
        <version>${vertx.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>io.smallrye.reactive</groupId>
        <artifactId>smallrye-mutiny-vertx-web</artifactId>
        <version>${smallrye-mutiny-vertx-bindings.version}</version>
        <scope>test</scope>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>${maven-assembly-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven-install-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven-clean-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven-resources-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>com.google.googlejavaformat</groupId>
          <artifactId>google-java-format</artifactId>
          <version>${google-java-format.version}</version>
        </plugin>
        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <version>${spotless-maven-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${maven-deploy-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
          <source>11</source>
          <target>11</target>
          <encoding>UTF-8</encoding>
          <compilerArgs>
            <arg>-XDcompilePolicy=simple</arg>
            <arg>-Xplugin:ErrorProne \
              -Xep:MissingCasesInEnumSwitch:OFF \
              -Xep:MissingOverride:ERROR \
              -Xep:MissingSummary:OFF \
              -Xep:NonOverridingEquals:OFF \
              -Xep:OperatorPrecedence:OFF \
              -Xep:ReferenceEquality:OFF \
              -Xep:UnnecessaryParentheses:OFF \
              -Xplugin:ErrorProne \
              -XepOpt:NullAway:AnnotatedPackages=com.redhat.insights \
              -Xep:NullAway:ERROR \
              -XepOpt:NullAway:JSpecifyMode \
              -XepExcludedPaths:.*/target/generated-(|test-)sources/.*</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
            <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
          </compilerArgs>
          <annotationProcessorPaths>
            <path>
              <groupId>com.google.errorprone</groupId>
              <artifactId>error_prone_core</artifactId>
              <version>${error-prone.version}</version>
            </path>
            <!-- Other annotation processors go here.

            If 'annotationProcessorPaths' is set, processors will no longer be
            discovered on the regular -classpath; see also 'Using Error Prone
            together with other annotation processors' below. -->
            <path>
              <groupId>com.uber.nullaway</groupId>
              <artifactId>nullaway</artifactId>
              <version>${nullaway.version}</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <excludedGroups>IntegrationTest</excludedGroups>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>${maven-jar-plugin.version}</version>
        <configuration>
          <archive>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>${spotless-maven-plugin.version}</version>
        <configuration>
          <skip>${skip.spotless}</skip>
          <!-- optional: limit format enforcement to just the files changed by this feature branch -->
          <ratchetFrom>origin/main</ratchetFrom>
          <formats>
            <!-- you can define as many formats as you want, each is independent -->
            <format>
              <!-- define the files to apply to -->
              <includes>
                <include>*.md</include>
                <include>.gitignore</include>
              </includes>
              <!-- define the steps to apply to those files -->
              <trimTrailingWhitespace></trimTrailingWhitespace>
              <endWithNewline></endWithNewline>
              <indent>
                <tabs>true</tabs>
                <spacesPerTab>4</spacesPerTab>
              </indent>
            </format>
          </formats>
          <!-- define a language-specific format -->
          <java>
            <!-- no need to specify files, inferred automatically, but you can if you want -->

            <!-- apply a specific flavor of google-java-format and reflow long strings -->
            <googleJavaFormat>
              <version>${google-java-format.version}</version>
              <style>GOOGLE</style>
              <reflowLongStrings>true</reflowLongStrings>
              <groupArtifact>com.google.googlejavaformat:google-java-format</groupArtifact>
            </googleJavaFormat>

            <!-- make sure every file has the following copyright header.
			           optionally, Spotless can set copyright years by digging
			           through git history (see "license" section below) -->
            <licenseHeader>
              <content>/* Copyright (C) Red Hat $YEAR */</content>
              <!-- or <file>${project.basedir}/license-header</file> -->
            </licenseHeader>
          </java>
          <pom>
            <includes>
              <include>pom.xml</include>
            </includes>
            <sortPom></sortPom>
          </pom>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>compile</phase>
          </execution>
        </executions>
      </plugin>

    </plugins>

  </build>

  <profiles>

    <profile>
      <id>coverage</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco-maven-plugin.version}</version>
            <executions>
              <execution>
                <id>default-prepare-agent</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
              </execution>
              <execution>
                <id>default-report</id>
                <goals>
                  <goal>report</goal>
                </goals>
                <phase>test</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>integration</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludedGroups>none</excludedGroups>
            </configuration>
          </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>
              <projectVersionPattern>SEMVER</projectVersionPattern>
              <jreleaser>
                <signing>
                  <active>ALWAYS</active>
                  <armored>true</armored>
                </signing>
                <release>
                  <github>
                    <owner>RedHatInsights</owner>
                    <changelog>
                      <preset>conventional-commits</preset>
                      <links>true</links>
                      <formatted>ALWAYS</formatted>
                      <hide>
                        <contributors>
                          <contributor>GitHub</contributor>
                          <contributor>dependabot[bot]</contributor>
                          <contributor>bot</contributor>
                        </contributors>
                      </hide>
                    </changelog>
                  </github>
                </release>
                <deploy>
                  <maven>
                    <pomchecker>
                      <failOnWarning>false</failOnWarning>
                      <failOnError>false</failOnError>
                    </pomchecker>
                    <nexus2>
                      <maven-central>
                        <active>ALWAYS</active>
                        <url>https://oss.sonatype.org/service/local</url>
                        <snapshotUrl>https://oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
                        <closeRepository>true</closeRepository>
                        <releaseRepository>true</releaseRepository>
                        <stagingRepositories>target/staging-deploy</stagingRepositories>
                      </maven-central>
                    </nexus2>
                  </maven>
                </deploy>
              </jreleaser>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </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>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <attach>true</attach>
                </configuration>
              </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>
                  <goal>test-jar-no-fork</goal>
                </goals>
                <configuration>
                  <attach>true</attach>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
</project>
