<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2018, 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:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://maven.apache.org/POM/4.0.0"
        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>
        <groupId>io.helidon.metrics</groupId>
        <artifactId>helidon-metrics-project</artifactId>
        <version>3.2.2</version>
    </parent>
    <artifactId>helidon-metrics</artifactId>
    <name>Helidon Metrics</name>

    <description>
        Metrics APIs and implementation necessary for Java SE using Helidon Web Server
    </description>

    <properties>
        <spotbugs.exclude>etc/spotbugs/exclude.xml</spotbugs.exclude>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.helidon.common</groupId>
            <artifactId>helidon-common</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.common</groupId>
            <artifactId>helidon-common-service-loader</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.common</groupId>
            <artifactId>helidon-common-configurable</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.metrics</groupId>
            <artifactId>helidon-metrics-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.metrics</groupId>
            <artifactId>helidon-metrics-service-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.metrics</groupId>
            <artifactId>microprofile-metrics-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.webserver</groupId>
            <artifactId>helidon-webserver</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.webserver</groupId>
            <artifactId>helidon-webserver-cors</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.media</groupId>
            <artifactId>helidon-media-jsonp</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.config</groupId>
            <artifactId>helidon-config</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.service-common</groupId>
            <artifactId>helidon-service-common-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.webclient</groupId>
            <artifactId>helidon-webclient</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>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>default-test</id>
                            <configuration>
                                <excludes>
                                    <exclude>**/TestServerWithKeyPerformanceIndicatorMetrics.java</exclude>
                                    <exclude>**/TestExponentiallyDecayingReservoir.java</exclude>
                                    <exclude>**/TestDisabledEntirely.java</exclude>
                                </excludes>
                            </configuration>
                        </execution>
                        <execution>
                            <!-- Run this test in default-test and also here with an env var set -->
                            <id>metrics-global-tags-set</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <includes>
                                <include>**/InternalBridgeTest.java</include>
                            </includes>
                            <environmentVariables>
                                <MP_METRICS_TAGS>globalTag1=gVal1,globalTag2=gVal2</MP_METRICS_TAGS>
                            </environmentVariables>
                            </configuration>
                        </execution>
                        <execution>
                            <!-- Run in separate invocation so service loader gets the correct, non-default set-up. -->
                            <id>key-performance-indicator-metrics-enabled</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <includes>
                                    <include>**/TestServerWithKeyPerformanceIndicatorMetrics.java</include>
                                </includes>
                            </configuration>
                        </execution>
                        <execution>
                            <!-- Run in separate invocation so we have only one task updating
                                 ExponentiallyDecayingReservoir current time values. -->
                            <id>exponentially-decaying-reservoir-check</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <includes>
                                    <include>**/TestExponentiallyDecayingReservoir.java</include>
                                </includes>
                            </configuration>
                        </execution>
                        <execution>
                            <!-- Run in separate invocation to make sure the RegistryFactory is initialized correctly. -->
                            <id>check-metrics-entirely-disabled</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <includes>
                                    <include>**/TestDisabledEntirely.java</include>
                                </includes>
                            </configuration>
                        </execution>
                    </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>pipeline</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <helidon.concurrentGauge.minRequiredSeconds>45</helidon.concurrentGauge.minRequiredSeconds>
                                <helidon.histogram.tolerance>0.25</helidon.histogram.tolerance>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
