<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.wildfly.a2a</groupId>
        <artifactId>a2a-java-sdk-jakarta-parent</artifactId>
        <version>1.0.0.Alpha2</version>
    </parent>

    <artifactId>a2a-java-sdk-jakarta-tck-wildfly</artifactId>

    <packaging>war</packaging>

    <name>WildFly Extras - Java A2A SDK for Jakarta - TCK - WildFly Jar</name>
    <description>Java SDK for the Agent2Agent Protocol (A2A) - SDK - Jakarta - TCK - WildFly Jar</description>

    <dependencies>
        <!--
            Dependencies needed to build the application.
        -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>a2a-java-sdk-jakarta-jsonrpc</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>a2a-java-sdk-jakarta-grpc</artifactId>
            <version>${project.version}</version>
            <!-- Exclude gRPC core libraries as they are provided by WildFly's gRPC feature pack -->
            <exclusions>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.protobuf</groupId>
                    <artifactId>protobuf-java</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>a2a-java-sdk-jakarta-rest</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!--
            This is not strictly needed, but if you want to configure the a2a-java further as mentioned in
            https://github.com/a2aproject/a2a-java/blob/main/README.md#4-configuration-system
            via MicroProfile Config, this jar needs to be included.
        -->
        <dependency>
            <groupId>io.github.a2asdk</groupId>
            <artifactId>a2a-java-sdk-microprofile-config</artifactId>
            <scope>provided</scope>
        </dependency>


        <!--
            Include the TCK server from the a2a-java project.
            This is the application we will be using, providing the AgentExecutor and the AgentCard.
            For your own applications you should not use this dependency, but rather provide your own.
        -->
        <dependency>
            <groupId>io.github.a2asdk</groupId>
            <artifactId>a2a-tck-server</artifactId>
            <exclusions>
                <!--
                    Exclude all dependencies, since we are managing what is included in the jar in the
                    org.wildfly.extras.a2a:ctId>a2a-java-sdk-jakarta dependency.
                -->
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!--
                WildFly specific plugin to provision a WildFly server with the functionality required to
                run our .war file.
                It deploys the war renamed to 'ROOT.war' so that it is deployed under the root context, i.e. under '/'.
                By default, this will be under http://localhost:8080/.
            -->
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <configuration>
                     <feature-packs>
                        <feature-pack>
                            <groupId>org.wildfly</groupId>
                            <artifactId>wildfly-galleon-pack</artifactId>
                            <version>${version.wildfly}</version>
                        </feature-pack>
                        <!-- Add gRPC feature pack -->
                        <feature-pack>
                            <groupId>org.wildfly.extras.grpc</groupId>
                            <artifactId>wildfly-grpc-feature-pack</artifactId>
                            <version>${version.wildfly.grpc}</version>
                        </feature-pack>
                    </feature-packs>
                    <discover-provisioning-info>
                        <add-ons>
                            <add-on>grpc</add-on>
                        </add-ons>
                    </discover-provisioning-info>
                    <jboss-home>${jboss.home}</jboss-home>
                    <name>ROOT.war</name>
                    <provisioning-dir>${jboss.home}</provisioning-dir>
                    <!-- Set stability level to preview for gRPC feature pack -->
                    <galleon-options>
                        <jboss-fork-embedded>true</jboss-fork-embedded>
                        <stability-level>preview</stability-level>
                    </galleon-options>
                    <!-- CLI scripts are incompatible with preview stability level during provisioning -->
                    <!--
                    <packagingScripts>
                        <packaging-script>
                            <scripts>
                                <script>./src/scripts/configure_logger.cli</script>
                            </scripts>
                        </packaging-script>
                    </packagingScripts>
                    -->
                </configuration>
                <executions>
                    <execution>
                        <id>provisioning</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
