<?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/maven-v4_0_0.xsd">
  <parent>
    <artifactId>client_java</artifactId>
    <groupId>io.prometheus</groupId>
    <version>1.3.10</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>prometheus-metrics-exporter-opentelemetry</artifactId>
  <packaging>bundle</packaging>
  <name>Prometheus Metrics to OpenTelemetry Exporter</name>
  <description>Converts Prometheus metrics to OpenTelemetry format and pushes them to an OTLP endpoint</description>
  <build>
    <resources>
      <resource>
        <filtering>true</filtering>
        <directory>target/metrics-exporter-opentelemetry/src/main/resources-filtered</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-metrics-exporter-opentelemetry-main</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>target/metrics-exporter-opentelemetry/src/main</outputDirectory>
              <resources>
                <resource>
                  <directory>../prometheus-metrics-exporter-opentelemetry/src/main</directory>
                </resource>
                <resources />
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-metrics-exporter-opentelemetry-test</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>target/metrics-exporter-opentelemetry/src/test</outputDirectory>
              <resources>
                <resource>
                  <directory>../prometheus-metrics-exporter-opentelemetry/src/test</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>regex-property</id>
            <goals>
              <goal>regex-property</goal>
            </goals>
            <configuration>
              <name>otel.instrumentation.string-version</name>
              <value>${otel.instrumentation.version}</value>
              <regex>[\.-]</regex>
              <replacement>_</replacement>
              <failIfNoMatch>true</failIfNoMatch>
            </configuration>
          </execution>
          <execution>
            <id>metrics-exporter-opentelemetry-main</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>target/metrics-exporter-opentelemetry/src/main/java</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-metrics-exporter-opentelemetry-test</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>target/metrics-exporter-opentelemetry/src/test/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <artifactSet>
                <includes>
                  <include>io.opentelemetry:*</include>
                  <include>io.opentelemetry.semconv:*</include>
                  <include>io.opentelemetry.instrumentation:*</include>
                  <include>com.squareup.*:*</include>
                  <include>org.jetbrains:*</include>
                  <include>org.jetbrains.*:*</include>
                </includes>
              </artifactSet>
              <relocations>
                <relocation>
                  <pattern>io.opentelemetry</pattern>
                  <shadedPattern>io.prometheus.metrics.shaded.io_opentelemetry_${otel.instrumentation.string-version}</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>io.opentelemetry.instrumentation</pattern>
                  <shadedPattern>io.prometheus.metrics.shaded.io_opentelemetry_${otel.instrumentation.string-version}.instrumentation</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>io.opentelemetry.semconv</pattern>
                  <shadedPattern>io.prometheus.metrics.shaded.io_opentelemetry_${otel.instrumentation.string-version}.semconv</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>okhttp3</pattern>
                  <shadedPattern>io.prometheus.metrics.shaded.io_opentelemetry_${otel.instrumentation.string-version}.okhttp3</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>kotlin</pattern>
                  <shadedPattern>io.prometheus.metrics.shaded.io_opentelemetry_${otel.instrumentation.string-version}.kotlin</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.intellij</pattern>
                  <shadedPattern>io.prometheus.metrics.shaded.io_opentelemetry_${otel.instrumentation.string-version}.org.intellij</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.jetbrains</pattern>
                  <shadedPattern>io.prometheus.metrics.shaded.io_opentelemetry_${otel.instrumentation.string-version}.org.jetbrains</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>okio</pattern>
                  <shadedPattern>io.prometheus.metrics.shaded.io_opentelemetry_${otel.instrumentation.string-version}.okio</shadedPattern>
                </relocation>
              </relocations>
              <transformers>
                <transformer />
              </transformers>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>lib/opentelemetry-*</exclude>
                    <exclude>META-INF/maven/org.jctools/**</exclude>
                    <exclude>META-INF/maven/org.jetbrains/**</exclude>
                    <exclude>META-INF/versions/**</exclude>
                    <exclude>META-INF/native-image/**</exclude>
                    <exclude>META-INF/proguard/**</exclude>
                    <exclude>META-INF/*.kotlin_module</exclude>
                    <exclude>META-INF/MANIFEST.MF</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>javadoc</id>
    </profile>
    <profile>
      <id>release</id>
    </profile>
    <profile>
      <dependencies>
        <dependency>
          <groupId>io.opentelemetry</groupId>
          <artifactId>opentelemetry-proto</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>io.opentelemetry</groupId>
          <artifactId>opentelemetry-sdk-testing</artifactId>
          <scope>test</scope>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
  <dependencies>
    <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-core</artifactId>
      <version>1.3.10</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-exporter-opentelemetry-otel-agent-resources</artifactId>
      <version>1.3.10</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <version>3.0.2</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.opentelemetry.instrumentation</groupId>
        <artifactId>opentelemetry-instrumentation-bom-alpha</artifactId>
        <version>${otel.instrumentation.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <properties>
    <automatic.module.name>io.prometheus.metrics.exporter.opentelemetry</automatic.module.name>
  </properties>
</project>
