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

  <parent>
    <groupId>io.prometheus</groupId>
    <artifactId>client_java</artifactId>
    <version>1.7.0</version>
  </parent>

  <artifactId>prometheus-metrics-exporter-opentelemetry-otel-agent-resources</artifactId>
  <packaging>bundle</packaging>

  <name>OpenTelemetry Agent Resource Extractor</name>
  <description>
    Reads the OpenTelemetry Agent resources the GlobalOpenTelemetry instance
  </description>

  <properties>
    <automatic.module.name>io.prometheus.otel.resource.attributes</automatic.module.name>
    <!-- don't update with dependabot, the Otel agent can handle older versions -->
    <otel-dynamic-load.version>1.29.0</otel-dynamic-load.version>
    <!-- Lower coverage threshold: OTel agent integration requires runtime agent attachment -->
    <jacoco.line-coverage>0.50</jacoco.line-coverage>
  </properties>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>validate</phase>
            <goals>
              <goal>copy</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>io.opentelemetry</groupId>
              <artifactId>opentelemetry-api</artifactId>
              <version>${otel-dynamic-load.version}</version>
              <outputDirectory>${project.basedir}/src/main/resources/lib/</outputDirectory>
            </artifactItem>
            <artifactItem>
              <groupId>io.opentelemetry</groupId>
              <artifactId>opentelemetry-context</artifactId>
              <version>${otel-dynamic-load.version}</version>
              <outputDirectory>${project.basedir}/src/main/resources/lib/</outputDirectory>
            </artifactItem>
          </artifactItems>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/io/opentelemetry/**</exclude>
          </excludes>
        </configuration>
        <executions>
          <execution>
            <id>check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <rules>
                <rule>
                  <element>CLASS</element>
                  <limits>
                    <limit>
                      <counter>LINE</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${jacoco.line-coverage}</minimum>
                    </limit>
                  </limits>
                  <excludes>
                    <exclude>io.opentelemetry.**</exclude>
                  </excludes>
                </rule>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
