<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.mule.extensions</groupId>
        <artifactId>mule-ee-core-modules-parent</artifactId>
        <version>1.9.8</version>
    </parent>

    <groupId>com.mulesoft.modules</groupId>
    <artifactId>mule-agent-router-module</artifactId>
    <version>0.8.2</version>
    <packaging>mule-extension</packaging>

    <name>Mule Agent Loop connector</name>

    <properties>
        <java.release.version>17</java.release.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <muleHttpConnector.version>1.11.0</muleHttpConnector.version>
        <a2a.connector.version>1.1.0</a2a.connector.version>
        <mcp.connector.version>1.3.1</mcp.connector.version>
        <a2a.sdk.version>0.3.3.Final</a2a.sdk.version>
        <openai.sdk.version>4.21.0</openai.sdk.version>
        <google.genai.version>1.41.0</google.genai.version>
        <caffeine.version>3.2.3</caffeine.version>
        <jacoco.version>0.8.11</jacoco.version>
        <aspectjVersion>1.9.22.1</aspectjVersion>
        <commons.text.version>1.14.0</commons.text.version>

        <!-- Remove when a new parent version with MTF is available -->
        <munit.input.directory>src/test/munit</munit.input.directory>
        <munit.output.directory>${basedir}/target/test-mule/munit</munit.output.directory>
        <munit.extensions.maven.plugin.version>1.6.1</munit.extensions.maven.plugin.version>
        <munit.version>3.6.3</munit.version>
        <mtf-tools.version>1.2.0</mtf-tools.version>
        <mavenResources.version>3.3.1</mavenResources.version>
        <munitMinMuleVersion>4.11.2</munitMinMuleVersion>

        <mulesoftLicenseVersion>1.4.0</mulesoftLicenseVersion>
        <license.maven.plugin.version>4.6</license.maven.plugin.version>
        <licensePath>LICENSE_HEADER.txt</licensePath>
        <licenseYear>2025</licenseYear>

        <sonar.exclusions>
            **/com/mulesoft/connectors/loop/api/model/**/*
        </sonar.exclusions>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.genai</groupId>
            <artifactId>google-genai</artifactId>
            <version>${google.genai.version}</version>
        </dependency>
        <dependency>
            <groupId>com.openai</groupId>
            <artifactId>openai-java</artifactId>
            <version>${openai.sdk.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.a2asdk</groupId>
            <artifactId>a2a-java-sdk-spec</artifactId>
            <version>${a2a.sdk.version}</version>
        </dependency>
        <dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>caffeine</artifactId>
            <version>${caffeine.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <version>${commons.text.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jsonSchema</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mule.connectors</groupId>
            <artifactId>mule-http-connector</artifactId>
            <version>${muleHttpConnector.version}</version>
            <classifier>mule-plugin</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.munit</groupId>
            <artifactId>mtf-tools</artifactId>
            <version>${mtf-tools.version}</version>
            <classifier>mule-plugin</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.connectors</groupId>
            <artifactId>mule4-a2a-connector</artifactId>
            <version>${a2a.connector.version}</version>
            <classifier>mule-plugin</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.connectors</groupId>
            <artifactId>mule-mcp-connector</artifactId>
            <version>${mcp.connector.version}</version>
            <classifier>mule-plugin</classifier>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${mavenResources.version}</version>
                <executions>
                    <execution>
                        <id>copy-munit-resources</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${munit.output.directory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${munit.input.directory}</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.mulesoft.munit</groupId>
                <artifactId>munit-extensions-maven-plugin</artifactId>
                <version>${munit.extensions.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                    </execution>
                </executions>
                <configuration>
                    <argLines>
                        <!--Config for debugging locally -->
<!--                        <argLine>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</argLine>-->
                        <argLine>
                            -XX:+IgnoreUnrecognizedVMOptions
                        </argLine>
                        <argLine>
                            -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${session.executionRootDirectory}/target/jacoco.exec
                        </argLine>
                    </argLines>
                    <systemPropertyVariables>
                        <maf.openai.key>${env.MAF_OPENAI_KEY}</maf.openai.key>
                        <maf.gemini.key>${env.MAF_GEMINI_KEY}</maf.gemini.key>
                        <mule.openTelemetry.tracer.exporter.enabled>true</mule.openTelemetry.tracer.exporter.enabled>
                        <mule.openTelemetry.tracer.exporter.sampler.type>always_off</mule.openTelemetry.tracer.exporter.sampler.type>
                        <mule.openTelemetry.tracer.exporter.sampler.arg>1</mule.openTelemetry.tracer.exporter.sampler.arg>
                        <munit.disable.lazy.connections>true</munit.disable.lazy.connections>
                        <munit.test.timeout>60000</munit.test.timeout>
                    </systemPropertyVariables>

                    <!-- Configuration for local builds, in Jenkins we configure this via command
                    line arguments -->
                    <runtimeConfiguration>
                        <!-- Versions with support and snapshots -->
                        <discoverRuntimes>
                            <product>EE</product>
                            <minMuleVersion>${munitMinMuleVersion}</minMuleVersion>
                            <!-- TODO: change to true -->
                            <includeSnapshots>false</includeSnapshots>
                            <latestPatches>false</latestPatches>
                        </discoverRuntimes>
                    </runtimeConfiguration>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>munit-runner</artifactId>
                        <version>${munit.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>munit-tools</artifactId>
                        <version>${munit.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>mtf-tools</artifactId>
                        <version>${mtf-tools.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectjVersion}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <configuration>
                    <skipSource>true</skipSource>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <downloadUrl>http://www.mulesoft.org/display/MULE/Download</downloadUrl>
        <repository>
            <id>mule-releases</id>
            <name>Mule Release Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases</url>
        </repository>
        <snapshotRepository>
            <id>mule-snapshots</id>
            <name>Mule Snapshot Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/snapshots</url>
            <uniqueVersion>false</uniqueVersion>
        </snapshotRepository>
    </distributionManagement>
</project>
