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

    <groupId>io.github.markpollack</groupId>
    <artifactId>agent-judge-parent</artifactId>
    <version>0.13.0</version>
    <packaging>pom</packaging>

    <name>Agent Judge</name>
    <description>Agent Judge - LLM Output Evaluation Framework</description>
    <url>https://github.com/markpollack/agent-judge</url>

    <licenses>
        <license>
            <name>Business Source License 1.1</name>
            <url>https://github.com/markpollack/agent-judge/blob/main/LICENSE</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git://github.com/markpollack/agent-judge.git</connection>
        <developerConnection>scm:git:ssh://github.com:markpollack/agent-judge.git</developerConnection>
        <url>https://github.com/markpollack/agent-judge</url>
    </scm>

    <developers>
        <developer>
            <id>markpollack</id>
            <name>Mark Pollack</name>
            <email>mark.pollack@gmail.com</email>
        </developer>
    </developers>

    <modules>
        <module>agent-judge-core</module>
        <module>agent-judge-exec</module>
        <module>agent-judge-file</module>
        <module>agent-judge-llm</module>
        <module>agent-judge-koog</module>
        <module>agent-judge-langchain4j</module>
        <module>agent-judge-rag</module>
        <module>agent-judge-ai-core</module>
        <module>agent-judge-agent-client</module>
        <module>agent-judge-spring-ai</module>
    </modules>

    <properties>
        <!-- Java version -->
        <java.version>21</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Agent Judge project version -->
        <agent-judge.version>${project.version}</agent-judge.version>

        <!-- AgentClient version -->
        <agent-client.version>0.20.0</agent-client.version>

        <!-- Core dependency versions - aligned with Spring AI 2.0 -->
        <agent-sandbox-core.version>0.9.3</agent-sandbox-core.version>
        <spring-framework.version>7.0.2</spring-framework.version>
        <spring-ai.version>2.0.0</spring-ai.version>
        <spring-boot.version>4.0.7</spring-boot.version>
        <reactor.version>2024.0.5</reactor.version>
        <slf4j.version>2.0.9</slf4j.version>

        <!-- File comparison -->
        <javaparser.version>3.26.3</javaparser.version>
        <maven-model.version>3.9.6</maven-model.version>

        <!-- JSON processing -->
        <jackson.version>2.21.2</jackson.version>

        <!-- Test dependency versions -->
        <junit-jupiter.version>5.10.1</junit-jupiter.version>
        <mockito.version>5.7.0</mockito.version>
        <assertj.version>3.24.2</assertj.version>

        <!-- Plugin versions -->
        <maven-source-plugin.version>3.3.0</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.6.0</maven-javadoc-plugin.version>
        <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
        <central-publishing-maven-plugin.version>0.10.0</central-publishing-maven-plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Jackson BOM (imported first so it wins over the Spring BOMs) -->
            <dependency>
                <groupId>com.fasterxml.jackson</groupId>
                <artifactId>jackson-bom</artifactId>
                <version>${jackson.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- Spring Framework BOM -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-framework-bom</artifactId>
                <version>${spring-framework.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- Spring Boot BOM -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- Reactor BOM -->
            <dependency>
                <groupId>io.projectreactor</groupId>
                <artifactId>reactor-bom</artifactId>
                <version>${reactor.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- Spring AI BOM -->
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-bom</artifactId>
                <version>${spring-ai.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- Spring AI dependencies -->
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-client-chat</artifactId>
                <version>${spring-ai.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-model</artifactId>
                <version>${spring-ai.version}</version>
            </dependency>

            <!-- Sandbox for process execution (remains under original coordinates) -->
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-sandbox-core</artifactId>
                <version>${agent-sandbox-core.version}</version>
            </dependency>

            <!-- AgentClient for CLI-delegated agent bridge -->
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-client-core</artifactId>
                <version>${agent-client.version}</version>
            </dependency>

            <!-- Slf4j API -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>

            <!-- Project modules -->
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-judge-core</artifactId>
                <version>${agent-judge.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-judge-exec</artifactId>
                <version>${agent-judge.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-judge-file</artifactId>
                <version>${agent-judge.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-judge-llm</artifactId>
                <version>${agent-judge.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-judge-ai-core</artifactId>
                <version>${agent-judge.version}</version>
            </dependency>

            <!-- File comparison dependencies -->
            <dependency>
                <groupId>com.github.javaparser</groupId>
                <artifactId>javaparser-core</artifactId>
                <version>${javaparser.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.maven</groupId>
                <artifactId>maven-model</artifactId>
                <version>${maven-model.version}</version>
            </dependency>

            <!-- Testing dependencies -->
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>${junit-jupiter.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>${mockito.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>${assertj.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Spring Boot starter logging for all test modules -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <distributionManagement>
        <snapshotRepository>
            <id>central</id>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>central-snapshots</id>
            <name>Maven Central Snapshots</name>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <profiles>
        <!-- OWASP dependency-check: build-time CVE gate (fails on HIGH+). Run: ./mvnw -Powasp verify -->
        <profile>
            <id>owasp</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.owasp</groupId>
                        <artifactId>dependency-check-maven</artifactId>
                        <version>12.1.0</version>
                        <configuration>
                            <failBuildOnCVSS>7.0</failBuildOnCVSS>
                            <ossindexAnalyzerEnabled>false</ossindexAnalyzerEnabled>
                        </configuration>
                        <executions>
                            <execution>
                                <goals><goal>check</goal></goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>failsafe</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>3.1.2</version>
                        <configuration>
                            <environmentVariables>
                                <ANTHROPIC_API_KEY>${env.ANTHROPIC_API_KEY}</ANTHROPIC_API_KEY>
                                <OPENAI_API_KEY>${env.OPENAI_API_KEY}</OPENAI_API_KEY>
                            </environmentVariables>
                            <rerunFailingTestsCount>2</rerunFailingTestsCount>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- Flatten POM for Maven Central -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>flatten-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <configuration>
                            <flattenMode>ossrh</flattenMode>
                        </configuration>
                        <executions>
                            <execution>
                                <id>flatten</id>
                                <phase>process-resources</phase>
                                <goals><goal>flatten</goal></goals>
                            </execution>
                            <execution>
                                <id>flatten.clean</id>
                                <phase>clean</phase>
                                <goals><goal>clean</goal></goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Maven Central Publishing Plugin -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>

                    <!-- GPG Signing -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Source JAR -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven-source-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Javadoc JAR -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <configuration>
                            <failOnError>false</failOnError>
                            <quiet>true</quiet>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.14.0</version>
                    <configuration>
                        <release>${java.version}</release>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.5.2</version>
                    <configuration>
                        <environmentVariables>
                            <ANTHROPIC_API_KEY>${env.ANTHROPIC_API_KEY}</ANTHROPIC_API_KEY>
                            <OPENAI_API_KEY>${env.OPENAI_API_KEY}</OPENAI_API_KEY>
                        </environmentVariables>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
