<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>dev.dokimos</groupId>
        <artifactId>dokimos-parent</artifactId>
        <version>0.23.0</version>
    </parent>

    <artifactId>dokimos-embabel</artifactId>
    <name>Dokimos :: Integration :: Embabel</name>
    <description>Embabel agent integration for Dokimos</description>

    <properties>
        <!-- Embabel's published jars are compiled for Java 21, so this module raises the baseline
             above the repo-wide Java 17. The parent only includes it on JDK 21+ (the embabel profile). -->
        <maven.compiler.release>21</maven.compiler.release>
    </properties>

    <dependencies>
        <dependency>
            <groupId>dev.dokimos</groupId>
            <artifactId>dokimos-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.embabel.agent</groupId>
            <artifactId>embabel-agent-api</artifactId>
            <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-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <!--
          The cost/latency metrics test stubs AgentProcess.totalUsage()/totalCost(), which only exist
          on Embabel versions after the 0.3.5 floor. It lives in src/it/java and is compiled in normal
          builds (and the JDK 21/25 matrix, which pins the current Embabel), but is excluded from the
          adapter-compat 0.3.5 row, which runs with -P!embabel-metrics-it so the matrix can sweep
          versions whose AgentProcess predates those accessors. The adapter's main code calls them
          reflectively and degrades to null, so it stays source-compatible across the range.
        -->
        <profile>
            <id>embabel-metrics-it</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.6.0</version>
                        <executions>
                            <execution>
                                <id>add-metrics-it-source</id>
                                <phase>generate-test-sources</phase>
                                <goals>
                                    <goal>add-test-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>${project.basedir}/src/it/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
