<?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-client-parent</artifactId>
    <version>0.22.0</version>
    <packaging>pom</packaging>

    <name>Agent Client</name>
    <description>Autonomous CLI Agent Integrations for Spring AI</description>
    <url>https://github.com/markpollack/agent-client</url>

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

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

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

    <modules>
        <!-- Base modules first -->
        <module>agent-models/agent-model</module>
        <module>agent-models/agent-tck</module>
        <module>agent-client-core</module>
        <module>agent-client-spring-boot-autoconfigure</module>

        <!-- SDK modules -->
        <module>provider-sdks/gemini-cli-sdk</module>
        <module>provider-sdks/swe-agent-sdk</module>
        <module>provider-sdks/amp-cli-sdk</module>
        <module>provider-sdks/codex-cli-sdk</module>
        <module>provider-sdks/amazon-q-cli-sdk</module>

        <!-- Agent models that depend on base + SDKs -->
        <module>agent-models/agent-claude</module>
        <module>agent-models/agent-gemini</module>
        <module>agent-models/agent-swe</module>
        <module>agent-models/agent-amp</module>
        <module>agent-models/agent-codex</module>
        <module>agent-models/agent-amazon-q</module>
        <module>agent-models/agent-qwen-code</module>

        <!-- Spring Boot Starters -->
        <module>agent-starters</module>

        <!-- Core and agents that depend on everything -->
        <module>agent-launcher</module>
        <module>agents/hello-world-agent</module>
        <module>agents/hello-world-agent-ai</module>

        <!-- Documentation and samples last -->
        <!-- docs module removed (Antora replaced by Mintlify) -->
        <!-- samples are standalone projects, not published to Central -->

        <!-- Samples are standalone projects, not published to Maven Central -->
    </modules>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>flatten-maven-plugin</artifactId>
                        <version>${flatten-maven-plugin.version}</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>
                    <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>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.7</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>
                    <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>
                    <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>

        <profile>
            <id>failsafe</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>3.1.2</version>
                        <configuration>
                            <!-- Pass environment variables to test JVM for API keys -->
                            <environmentVariables>
                                <ANTHROPIC_API_KEY>${env.ANTHROPIC_API_KEY}</ANTHROPIC_API_KEY>
                                <GEMINI_API_KEY>${env.GEMINI_API_KEY}</GEMINI_API_KEY>
                                <GOOGLE_API_KEY>${env.GOOGLE_API_KEY}</GOOGLE_API_KEY>
                            </environmentVariables>
                            <!-- Rerun flaky streaming tests to handle intermittent CLI failures -->
                            <rerunFailingTestsCount>2</rerunFailingTestsCount>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <properties>
        <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>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Spring AI Agents project versions -->


        <!-- Core dependency versions -->
        <spring-ai.version>2.0.0</spring-ai.version>
        <spring-boot.version>4.0.7</spring-boot.version>
        <slf4j.version>2.0.9</slf4j.version>

        <!-- External SDK versions -->
        <claude-code-sdk.version>1.3.0</claude-code-sdk.version>
        <qwencode-sdk.version>0.0.3-alpha</qwencode-sdk.version>
        <agent-sandbox.version>0.9.3</agent-sandbox.version>

        <!-- Agent SDK specific versions -->
        <zt-exec.version>1.12</zt-exec.version>
        <jackson.version>2.21.2</jackson.version>
        <mcp-sdk.version>0.15.0</mcp-sdk.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>
        <testcontainers.version>1.20.4</testcontainers.version>
        <micrometer.version>1.15.0</micrometer.version>
        <reactor.version>3.7.6</reactor.version>

        <!-- Plugin versions -->
        <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
        <maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
        <maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
        <maven-source-plugin.version>3.3.0</maven-source-plugin.version>
        <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
        <maven-javadoc-plugin.version>3.6.0</maven-javadoc-plugin.version>
        <flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
        <central-publishing-maven-plugin.version>0.9.0</central-publishing-maven-plugin.version>
        <spring-javaformat-maven-plugin.version>0.0.47</spring-javaformat-maven-plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Jackson BOM - explicit pin, MUST come before Boot/AI BOMs so it wins -->
            <dependency>
                <groupId>com.fasterxml.jackson</groupId>
                <artifactId>jackson-bom</artifactId>
                <version>${jackson.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>

            <!-- 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>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-core</artifactId>
                <version>${spring-ai.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-retry</artifactId>
                <version>${spring-ai.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-test</artifactId>
                <version>${spring-ai.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-template-st</artifactId>
                <version>${spring-ai.version}</version>
            </dependency>

            <!-- Sandbox for process execution -->
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-sandbox-core</artifactId>
                <version>${agent-sandbox.version}</version>
            </dependency>

            <!-- zt-exec for process execution (used by CLI SDKs) -->
            <dependency>
                <groupId>org.zeroturnaround</groupId>
                <artifactId>zt-exec</artifactId>
                <version>${zt-exec.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-sandbox-core</artifactId>
                <version>${agent-sandbox.version}</version>
                <type>test-jar</type>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-sandbox-docker</artifactId>
                <version>${agent-sandbox.version}</version>
            </dependency>

            <!-- MCP Java SDK (Spring-independent core) -->
            <dependency>
                <groupId>io.modelcontextprotocol.sdk</groupId>
                <artifactId>mcp</artifactId>
                <version>${mcp-sdk.version}</version>
            </dependency>

            <!-- TestContainers for Docker sandbox -->
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>testcontainers-bom</artifactId>
                <version>${testcontainers.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </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-model</artifactId>
                <version>${project.version}</version>
            </dependency>
            <!-- Claude Code SDK (from Maven Central) -->
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>claude-code-sdk</artifactId>
                <version>${claude-code-sdk.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>gemini-cli-sdk</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>swe-agent-sdk</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>amp-cli-sdk</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>codex-cli-sdk</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-codex</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-claude</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-gemini</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-swe</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-amp</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-qwen-code</artifactId>
                <version>${project.version}</version>
            </dependency>
            <!-- Qwen Code SDK -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>qwencode-sdk</artifactId>
                <version>${qwencode-sdk.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-client-core</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.markpollack</groupId>
                <artifactId>agent-starter</artifactId>
                <version>${project.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>
            <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-observation-test</artifactId>
                <version>${micrometer.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>io.projectreactor</groupId>
                <artifactId>reactor-test</artifactId>
                <version>${reactor.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>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                        <parameters>true</parameters>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                    <configuration>
                        <!-- Pass environment variables to test JVM for API keys -->
                        <environmentVariables>
                            <ANTHROPIC_API_KEY>${env.ANTHROPIC_API_KEY}</ANTHROPIC_API_KEY>
                            <GEMINI_API_KEY>${env.GEMINI_API_KEY}</GEMINI_API_KEY>
                            <GOOGLE_API_KEY>${env.GOOGLE_API_KEY}</GOOGLE_API_KEY>
                        </environmentVariables>
                    </configuration>
                </plugin>
                <!-- Spring Boot Maven Plugin -->
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${maven-deploy-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- Note: central-publishing-maven-plugin is configured ONLY in the 'release' profile -->
            <!-- For SNAPSHOT deployments, standard maven-deploy-plugin uses distributionManagement config -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <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>
        <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>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

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