<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2021, 2023 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">
    <parent>
        <groupId>io.helidon.metrics</groupId>
        <artifactId>helidon-metrics-project</artifactId>
        <version>3.2.2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>helidon-metrics-api</artifactId>
    <name>Helidon Metrics API</name>

    <description>
        Loader for metrics implementation and a no-op implementation
    </description>

    <dependencies>
        <dependency>
            <groupId>io.helidon.common</groupId>
            <artifactId>helidon-common-service-loader</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.common</groupId>
            <artifactId>helidon-common-http</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.config</groupId>
            <artifactId>helidon-config</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.config</groupId>
            <artifactId>helidon-config-metadata</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.metrics</groupId>
            <artifactId>microprofile-metrics-api</artifactId>
        </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>io.helidon.config</groupId>
            <artifactId>helidon-config-yaml</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>io.helidon.config</groupId>
                            <artifactId>helidon-config-metadata-processor</artifactId>
                            <version>${helidon.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <excludes>
                                <!-- Avoid any config pollution -->
                                <exclude>**/TestGlobalTags.java</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Without the bug fix, this test fails with
                            java.lang.IllegalArgumentException: Error(s) in global tag expression: [Missing '=': topLevel]
                        -->
                        <id>check-top-level-tags-only</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <systemPropertyVariables>
                                <testSelection>topLevel</testSelection>
                            </systemPropertyVariables>
                            <environmentVariables>
                                <tags>topLevel</tags>
                            </environmentVariables>
                            <includes>
                                <include>**/TestGlobalTags.java</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Without the bug fix, this test fails with
                            java.lang.IllegalArgumentException: Error(s) in global tag expression: [Missing '=': topLevel]
                        -->
                        <id>check-top-level-and-metrics-level-tags</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <systemPropertyVariables>
                                <testSelection>topLevelAndMetricsLevel</testSelection>
                                <!-- Use properties for the metrics global tag instead of env var;
                                     dots in env names seem to not always work. -->
                                <metrics.tags>myTag=myValue</metrics.tags>
                            </systemPropertyVariables>
                            <environmentVariables>
                                <tags>topLevel</tags>
                            </environmentVariables>
                            <includes>
                                <include>**/TestGlobalTags.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>