<?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.citrusframework</groupId>
    <artifactId>citrus-tools</artifactId>
    <version>5.0.0-M2</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>citrus-mcp-server</artifactId>
  <name>Citrus :: Tools :: MCP Server</name>
  <description>Citrus MCP Server</description>

  <properties>
    <!-- Build uber-jar for easy JBang execution -->
    <quarkus.package.jar.type>uber-jar</quarkus.package.jar.type>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.quarkus.platform</groupId>
        <artifactId>quarkus-bom</artifactId>
        <version>${quarkus.platform.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- Quarkus MCP Server with STDIO transport -->
    <dependency>
      <groupId>io.quarkiverse.mcp</groupId>
      <artifactId>quarkus-mcp-server-stdio</artifactId>
      <version>${quarkus.mcp-server.version}</version>
    </dependency>
    <!-- Quarkus MCP Server with HTTP/SSE transport -->
    <dependency>
      <groupId>io.quarkiverse.mcp</groupId>
      <artifactId>quarkus-mcp-server-http</artifactId>
      <version>${quarkus.mcp-server.version}</version>
    </dependency>

    <!-- Quarkus core dependencies -->
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-arc</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jackson</artifactId>
    </dependency>

    <dependency>
      <groupId>tools.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>

    <!-- Citrus dependencies -->
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-base</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>${project.build.directory}/generated-resources</directory>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-schema</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>java</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <includeProjectDependencies>false</includeProjectDependencies>
          <includePluginDependencies>true</includePluginDependencies>
          <executableDependency>
            <groupId>org.citrusframework</groupId>
            <artifactId>citrus-schema-generator</artifactId>
          </executableDependency>
          <mainClass>org.citrusframework.dsl.schema.generator.CitrusSchemaGenerator</mainClass>
          <arguments>
            <argument>${project.build.directory}/generated-resources/citrus-catalog</argument>
            <argument>${project.version}</argument>
          </arguments>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.citrusframework</groupId>
            <artifactId>citrus-schema-generator</artifactId>
            <version>${project.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>io.quarkus.platform</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <version>${quarkus.platform.version}</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
              <goal>generate-code</goal>
              <!-- generate-code-tests removed: tests don't use @QuarkusTest,
                   and the goal triggers a workspace resolution regression
                   in Quarkus 3.34+ (quarkusio/quarkus#53285) -->
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- Copy user manual .adoc files into the uber-JAR for runtime search -->
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-user-manual</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/generated-resources/manual</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.basedir}/../../src/manual</directory>
                  <filtering>false</filtering>
                  <includes>
                    <include>*.adoc</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Generate index.txt listing all copied user manual filenames -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-user-manual-index</id>
            <phase>process-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <fileset id="doc-files" dir="${project.build.directory}/generated-resources/manual">
                  <include name="*.adoc"/>
                </fileset>
                <pathconvert property="doc-list" refid="doc-files" pathsep="${line.separator}">
                  <flattenmapper/>
                </pathconvert>
                <echo file="${project.build.outputDirectory}/manual/index.txt"
                      message="${doc-list}"/>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <parameters>true</parameters>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven.surefire.plugin.version}</version>
        <configuration>
          <systemPropertyVariables>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
            <maven.home>${maven.home}</maven.home>
          </systemPropertyVariables>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit-platform</artifactId>
            <version>${maven.surefire.plugin.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

</project>
