<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.vaadin</groupId>
        <artifactId>observability-kit</artifactId>
        <version>5.0-SNAPSHOT</version>
    </parent>

    <artifactId>observability-kit-micrometer</artifactId>
    <packaging>jar</packaging>
    <name>Observability Kit :: Micrometer</name>
    <description>Framework-agnostic Micrometer instrumentation for Vaadin Flow.</description>

    <properties>
        <cvdl.name>vaadin-observability-kit</cvdl.name>
        <!--
            The in-browser collector's own test suite needs node on PATH. It
            follows -DskipTests like any other test, and -Dskip.js.tests=true
            turns off just this one, for a machine that has no node.
        -->
        <skipTests>false</skipTests>
        <skip.js.tests>${skipTests}</skip.js.tests>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>flow-server</artifactId>
        </dependency>
        <!--
            Dev-only: provides the DevToolsMessageHandler SPI used by the
            Copilot metrics panel. Optional so it is never pulled onto an
            application's production runtime classpath.
        -->
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-dev-server</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>license-checker</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-observation</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>context-propagation</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>${servlet.api.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>observability-kit.properties</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>observability-kit.properties</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <!--
                The in-browser collector's test suite, run by node with no
                dependencies and no runner. It is here because the location
                grammar exists in two languages: about 290 lines of
                StackFrames.java are hand-ported into VaadinMetricsClient.js,
                the two caps (MAX_LENGTH and DETAIL_MAX) have to stay equal,
                and this suite is the only thing that checks the browser copy,
                against the same corpus file the server's tests read. Run by
                hand, a one-sided change to either copy lands green, and the
                failure mode is silent: every client-error insight loses
                `frame` and `source`, which has shipped once already.
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>collector-js-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>node</executable>
                            <arguments>
                                <argument>${project.basedir}/src/test/js/VaadinMetricsClient.test.js</argument>
                            </arguments>
                            <!-- The suite exits non-zero on a failed check. -->
                            <skip>${skip.js.tests}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <CvdlName>${cvdl.name}</CvdlName>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
