<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2019 ITRS Group Ltd. All rights reserved. -->
<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.itrsgroup.collection</groupId>
  <artifactId>statsd-client</artifactId>
  <version>4.2.0</version>
  <packaging>jar</packaging>
  <name>Statsd Java Client</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jdk.version>17</jdk.version>

    <!-- SonarCloud settings. -->
    <sonar.organization>itrs-group</sonar.organization>
    <sonar.projectKey>${project.artifactId}</sonar.projectKey>
    <sonar.projectName>${project.artifactId}</sonar.projectName>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>5.5.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.1.1</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.3.1</version>
        <configuration>
          <filesets>
            <fileset>
              <directory>src/generated</directory>
              <includes>
                <include>*/**</include>
              </includes>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <source>${jdk.version}</source>
          <target>${jdk.version}</target>
          <compilerArgument>-Xlint:deprecation,unchecked</compilerArgument>
          <failOnError>true</failOnError>
          <failOnWarning>true</failOnWarning>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <consoleOutput>true</consoleOutput>
          <failOnViolation>true</failOnViolation>
          <violationSeverity>warning</violationSeverity>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>10.12.4</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>checkstyle-main</id>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <sourceDirectories>
                <sourceDirectory>src/main/java</sourceDirectory>
                <sourceDirectory>src/test/java</sourceDirectory>
              </sourceDirectories>
              <configLocation>checkstyle.xml</configLocation>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.6.1</version>
        <executions>
          <execution>
            <id>unpack-datamodel</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.itrsgroup.collection</groupId>
                  <artifactId>collection-datamodel</artifactId>
                  <version>4.2.0</version>
                  <classifier>sources</classifier>
                </artifactItem>
              </artifactItems>
              <includes>
                com/itrsgroup/collection/datamodel/Severity.java,
                com/itrsgroup/collection/datamodel/Unit.java
              </includes>
              <outputDirectory>src/generated/java</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.4.0</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/generated/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <archive>
            <manifestEntries>
              <Premain-Class>com.itrsgroup.collection.instr.jvm.JvmMetricsAgent</Premain-Class>
            </manifestEntries>
            <addMavenDescriptor>false</addMavenDescriptor>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.6.0</version>
        <configuration>
          <source>${jdk.version}</source>
          <failOnError>true</failOnError>
          <failOnWarnings>true</failOnWarnings>

          <!-- Java 17's linter is strict and requires comments on all public methods.
               There's currently no way to suppress the JavaDoc Lint warnings. An
               annotation has been added to Java 18 (https://bugs.openjdk.java.net/browse/JDK-8189591).
               If it gets back-ported to Java 17, we could add it to the relevant classes.
           -->
          <doclint>all,-missing</doclint>
        </configuration>
        <executions>
          <execution>
            <id>build-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.10</version>
        <executions>
          <execution>
            <id>agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <!-- IDs must match server IDs in settings.xml -->
  <distributionManagement>
    <snapshotRepository>
      <id>nexus-snapshots</id>
      <url>https://nexus.itrsgroup.com/repository/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>itrs-public</id>
      <url>https://maven.itrsgroup.com/repository/public</url>
    </repository>
  </distributionManagement>
</project>
