<?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.last9</groupId>
        <artifactId>vertx-otel-autoconfigure</artifactId>
        <version>2.2.0</version>
    </parent>

    <artifactId>vertx-otel-core</artifactId>
    <packaging>jar</packaging>

    <properties>
        <!-- vertx-otel-core is an internal module — it gets shaded into the two published JARs.
             It is published to Maven Central only because the central-publishing-maven-plugin
             bundles all staged artifacts regardless of skipPublishing=true. Consumers should
             depend on vertx4-rxjava3-otel-autoconfigure or vertx3-rxjava2-otel-autoconfigure
             instead, which include all required classes. -->
        <maven.deploy.skip>true</maven.deploy.skip>
    </properties>

    <name>Vert.x OTel Core</name>
    <description>
        Shared OpenTelemetry utilities: SDK auto-configuration, Logback MDC trace injection.
        No Vert.x dependency — used by both Vert.x 3 and Vert.x 4 modules.
    </description>

    <dependencies>
        <!-- OpenTelemetry SDK Auto-Configure -->
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
        </dependency>

        <!-- OpenTelemetry OTLP Exporter -->
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-otlp</artifactId>
        </dependency>

        <!-- JDK HTTP sender (replaces the default okhttp sender).
             opentelemetry-exporter-otlp pulls in opentelemetry-exporter-sender-okhttp by
             default, which requires okhttp3 on the classpath at runtime. Since we bundle
             OTel classes but not okhttp3 itself, that causes NoClassDefFoundError: okhttp3/Interceptor.
             The JDK sender uses Java 11's built-in HttpClient — no external dependency needed. -->
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-sender-jdk</artifactId>
        </dependency>

        <!-- OpenTelemetry Semantic Conventions -->
        <dependency>
            <groupId>io.opentelemetry.semconv</groupId>
            <artifactId>opentelemetry-semconv</artifactId>
        </dependency>

        <!-- OpenTelemetry Logback Appender (for log export via OTLP) -->
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-logback-appender-1.0</artifactId>
            <version>${opentelemetry-instrumentation.version}-alpha</version>
        </dependency>

        <!-- OpenTelemetry Logback MDC (for trace_id/span_id injection) -->
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-logback-mdc-1.0</artifactId>
            <version>${opentelemetry-instrumentation.version}-alpha</version>
        </dependency>

        <!-- JVM runtime metrics: memory, GC, threads, CPU, class-loading -->
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-runtime-telemetry-java8</artifactId>
            <version>${opentelemetry-instrumentation.version}-alpha</version>
        </dependency>

        <!-- Process/host/OS resource providers (process.pid, host.name, os.type, etc.).
             Registers ProcessResourceProvider, HostResourceProvider, OsResourceProvider via SPI
             so autoconfigure picks them up without manual attribute building. -->
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-resources</artifactId>
            <version>${opentelemetry-instrumentation.version}-alpha</version>
        </dependency>

        <!-- AWS resource detectors: EC2, ECS, EKS, Lambda, Elastic Beanstalk.
             Registered via SPI — autoconfigure picks them up automatically.
             Makes short HTTP calls to IMDS at startup; silently skips if not on AWS. -->
        <dependency>
            <groupId>io.opentelemetry.contrib</groupId>
            <artifactId>opentelemetry-aws-resources</artifactId>
            <version>${opentelemetry-contrib.version}</version>
        </dependency>

        <!-- Kotlin stdlib: okhttp 4.x is written in Kotlin, kotlin-stdlib is required at runtime.
             Bundled here so customers don't need to add it separately. -->
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>1.9.22</version>
        </dependency>

        <!-- OkHttp: required by opentelemetry-aws-resources (Ec2Resource calls EC2 IMDS via
             OkHttpClient). This is bundled into the fat JAR so the AWS detector works on EC2
             without requiring customers to add okhttp as a dependency.
             NOTE: opentelemetry-exporter-sender-okhttp is excluded from the shade; only the
             okhttp library itself (not its OTel sender SPI) is bundled here. -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.12.0</version>
        </dependency>

        <!-- GCP resource detectors: GCE, GKE, Cloud Run, App Engine.
             Registered via SPI — autoconfigure picks them up automatically.
             Makes short HTTP calls to GCP metadata server at startup; silently skips if not on GCP. -->
        <dependency>
            <groupId>io.opentelemetry.contrib</groupId>
            <artifactId>opentelemetry-gcp-resources</artifactId>
            <version>${opentelemetry-contrib.version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <!-- Skip Central Portal publishing for this internal-only module. -->
    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.6.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <skipPublishing>true</skipPublishing>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Automatic-Module-Name>io.last9.tracing.otel</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
