<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2023, 2025 Oracle and/or its affiliates.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
  -->

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>helidon-microprofile-project</artifactId>
        <groupId>io.helidon.microprofile</groupId>
        <version>4.3.2</version>
    </parent>
    <groupId>io.helidon.microprofile.telemetry</groupId>
    <artifactId>helidon-microprofile-telemetry</artifactId>
    <name>Helidon Microprofile Telemetry</name>

    <description>
        Support for MicroProfile Telemetry
    </description>

    <properties>
        <!-- The default for the following is 5000 ms. Reducing it speeds up tests significantly. -->
        <otel.bsp.schedule.delay>100</otel.bsp.schedule.delay>
        <spotbugs.exclude>etc/spotbugs/exclude.xml</spotbugs.exclude>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.helidon.tracing</groupId>
            <artifactId>helidon-tracing</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.tracing.providers</groupId>
            <artifactId>helidon-tracing-providers-opentelemetry</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry.instrumentation</groupId>
            <artifactId>opentelemetry-instrumentation-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-context</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.microprofile.server</groupId>
            <artifactId>helidon-microprofile-server</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.microprofile.config</groupId>
            <artifactId>helidon-microprofile-config</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.jersey</groupId>
            <artifactId>helidon-jersey-common</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.interceptor</groupId>
            <artifactId>jakarta.interceptor-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.helidon.common.features</groupId>
            <artifactId>helidon-common-features-api</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- testing -->
        <dependency>
            <groupId>io.helidon.logging</groupId>
            <artifactId>helidon-logging-jul</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.helidon.common.testing</groupId>
            <artifactId>helidon-common-testing-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-otlp</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.helidon.microprofile.testing</groupId>
            <artifactId>helidon-microprofile-testing-junit5</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>io.helidon.common.features</groupId>
                            <artifactId>helidon-common-features-codegen</artifactId>
                            <version>${helidon.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
                <executions>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <compilerArgs>
                                <!--
                                Used by a test to send requests with repeating header names.
                                -->
                                <arg>--add-modules</arg>
                                <arg>java.net.http</arg>
                            </compilerArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <systemPropertyVariables>
                                <otel.bsp.schedule.delay>${otel.bsp.schedule.delay}</otel.bsp.schedule.delay>
                                <otel.sdk.disabled>false</otel.sdk.disabled>
                            </systemPropertyVariables>
                            <excludes>
                                <exclude>**/AgentDetectorTest.java</exclude>
                                <exclude>**/TestSpanListenersWithInjection.java</exclude>
                                <exclude>**/TestFilterSpanNesting.java</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <!--
                        This test does not need an active OTel SDK so run it separately to prevent it from running first
                        and leaving other tests with a no-op Otel which will cause them to fail.
                         -->
                        <id>agent-detector-tests</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/AgentDetectorTest.java</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>callback-enabled-injection-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/TestSpanListenersWithInjection.java</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>filter-span-nesting-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/TestFilterSpanNesting.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
