<?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>6.5.0</version>
  <packaging>jar</packaging>
  <name>Statsd Java Client</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>21</java.version>
    <collection-datamodel.version>6.5.0</collection-datamodel.version>

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

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.opentelemetry</groupId>
        <artifactId>opentelemetry-bom</artifactId>
        <version>1.59.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>io.opentelemetry</groupId>
      <artifactId>opentelemetry-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.opentelemetry.semconv</groupId>
      <artifactId>opentelemetry-semconv</artifactId>
      <version>1.22.0-alpha</version>
    </dependency>
    <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.18.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>
          ${project.basedir}/licenses
        </directory>
      </resource>
    </resources>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.1.4</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.5.0</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.14.0</version>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
          <release>${java.version}</release>
          <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.6.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.26.1</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.8.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>${collection-datamodel.version}</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.6.1</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.4.2</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.11.2</version>
        <configuration>
          <source>${java.version}</source>
          <failOnError>true</failOnError>
          <failOnWarnings>true</failOnWarnings>
          <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.13</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>

  <profiles>
    <profile>
      <id>generate-oss-licenses</id>
      <activation>
        <property>
          <!-- Specify -DgenerateLicenses to enable. -->
          <name>generateLicenses</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <version>2.6.0</version>
            <configuration>
              <excludedScopes>test,provided</excludedScopes>
              <outputDirectory>${project.basedir}/licenses</outputDirectory>
              <licensesOutputDirectory>${project.basedir}/licenses</licensesOutputDirectory>
              <licensesOutputFile>${project.basedir}/licenses/licenses.xml</licensesOutputFile>
              <licensesConfigFile>${project.basedir}/licenses.xml</licensesConfigFile>
              <sortByGroupIdAndArtifactId>true</sortByGroupIdAndArtifactId>
              <failOnMissing>true</failOnMissing>
              <failOnBlacklist>true</failOnBlacklist>
              <errorRemedy>xmlOutput</errorRemedy>
              <licensesOutputFileEol>LF</licensesOutputFileEol>
              <offline>false</offline>
              <removeOrphanLicenseFiles>true</removeOrphanLicenseFiles>
              <connectionRequestTimeout>30000</connectionRequestTimeout>
              <socketTimeout>30000</socketTimeout>
              <connectTimeout>30000</connectTimeout>
              <useDefaultContentSanitizers>true</useDefaultContentSanitizers>
              <useDefaultUrlReplacements>true</useDefaultUrlReplacements>
              <acceptPomPackaging>true</acceptPomPackaging>
              <excludedGroups>^com\.itrsgroup</excludedGroups>
              <licenseUrlFileNames/>
              <licenseUrlReplacements/>
            </configuration>
            <executions>
              <execution>
                <id>download-third-party-licenses</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>download-licenses</goal>
                  <goal>add-third-party</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

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