<?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.3.2</version>
  </parent>

  <groupId>org.mule.modules</groupId>
  <artifactId>mule-graphql-module</artifactId>
  <version>1.2.1</version>
  <packaging>mule-extension</packaging>

  <name>APIKit for GraphQL Runtime Extension</name>

  <properties>
    <graphql-java.version>20.9</graphql-java.version>
    <graphql-java-extended-scalars.version>20.2</graphql-java-extended-scalars.version>
    <guava.version>32.1.1-jre</guava.version>
    <gson.version>2.12.0</gson.version>
    <slf4j.version>2.0.0-alpha7</slf4j.version>

    <!-- W-23230021-W-23230022: test/build stack aligned with main so the derived
         (matrixGeneration) JDK 17 lanes can boot the Mule embedded container. The
         older munit-extensions 1.4.0 admits both plexus-utils and legacy
         plexus.utils onto the JPMS module path exporting the same package ->
         ResolutionException -> "Cannot create embedded container" on every JDK 17
         lane (PR-173 builds #4/#5). All bumps below are test/build scope only; the
         shipped mule-plugin artifact's runtime dependencies are unchanged. -->
    <mtf-tools.version>1.3.0-rc3</mtf-tools.version>
    <munit.version>3.7.5</munit.version>
    <munit.extensions.maven.plugin.version>1.7.3</munit.extensions.maven.plugin.version>
    <!-- 1.9.22 knows Mule 4.3 ([1.8, 12)), which includes this module's Java 8 compile target.
         Release notes: Mule 4.3.0 and later. -->
    <mule.extensions.maven.plugin.version>1.9.22</mule.extensions.maven.plugin.version>
    <min.mule.version>4.3.0</min.mule.version>
    <munit.input.directory>src/test/munit</munit.input.directory>
    <jacoco.version>0.8.14</jacoco.version>
    <junit-jupiter.version>5.9.3</junit-jupiter.version>
    <byte-buddy.version>1.17.5</byte-buddy.version>

    <!-- Java 17 properties -->
    <muleSdkCompatibilityApiVersion>0.7.0</muleSdkCompatibilityApiVersion>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- Pin Byte Buddy to a J25-aware version (Mockito ships older 1.12.x which fails on Java class-file 69). -->
      <dependency>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy</artifactId>
        <version>${byte-buddy.version}</version>
      </dependency>
      <dependency>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy-agent</artifactId>
        <version>${byte-buddy.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>com.graphql-java</groupId>
      <artifactId>graphql-java</artifactId>
      <version>${graphql-java.version}</version>
    </dependency>
    <dependency>
      <groupId>com.graphql-java</groupId>
      <artifactId>graphql-java-extended-scalars</artifactId>
      <version>${graphql-java-extended-scalars.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>${gson.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>

    <!--Test-->
    <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>org.mule.connectors</groupId>
      <artifactId>mule-objectstore-connector</artifactId>
      <version>1.2.2</version>
      <classifier>mule-plugin</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit-jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mule.sdk</groupId>
      <artifactId>mule-sdk-compatibility-api</artifactId>
      <version>${muleSdkCompatibilityApiVersion}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.mule.runtime.plugins</groupId>
        <artifactId>mule-extensions-maven-plugin</artifactId>
        <configuration>
          <!-- This will always be complete list of all supported versions and not just new ones-->
          <supportedJavaVersions>
            <javaVersion>1.8</javaVersion>
            <javaVersion>11</javaVersion>
            <javaVersion>17</javaVersion>
            <javaVersion>21</javaVersion>
            <javaVersion>25</javaVersion>
          </supportedJavaVersions>
        </configuration>
        <!-- Parent SDK enum stops before 25. 1.2.1 is only on this plugin classpath. -->
        <dependencies>
          <dependency>
            <groupId>org.mule.sdk</groupId>
            <artifactId>mule-sdk-api</artifactId>
            <version>1.2.1</version>
          </dependency>
        </dependencies>
      </plugin>
      <!-- Parent 1.3.2 leaves Target-Java-Release-Version unset. extension-validate
           reads it from the jar manifest and fails when it is absent. 8 is rewritten to 1.8. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries combine.children="append">
              <Target-Java-Release-Version>8</Target-Java-Release-Version>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <!-- Addition-3 (W-23624366): let a force_redeploy recovery run skip a deploy
           that's already fully published, instead of hard-failing with a 400/409.
           check-deploy-skip.sh (apikit-sfci) writes the marker file(s) ONLY when that
           specific target already has every expected artifact; the read-project-properties
           execution is a quiet no-op any time its marker is absent, i.e. every normal
           release and every recovery run where nothing needs skipping.

           IMPORTANT: both deploys run in the SAME reactor when the internal deploy
           activates -Prelease-sfci, and every read-project-properties execution here
           collapses onto the single `maven.deploy.skip` property. So the PUBLIC marker
           is loaded here (default build, always active) and the INTERNAL marker is loaded
           ONLY under the release-sfci profile (see below) — the profile that uniquely
           identifies the internal deploy. This keeps the internal skip marker from leaking
           into the public deploy (the failure mode that left a version on internal Nexus
           but never published to public). Pin 1.0.0: 1.2.1 fails to resolve through this
           org's internal Nexus mirror. -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0.0</version>
        <executions>
          <execution>
            <id>sfci-check-public-deploy-skip</id>
            <phase>validate</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <quiet>true</quiet>
              <files>
                <file>${project.basedir}/.sfci-public-deploy-skip.properties</file>
              </files>
            </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>
            <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>
          <runtimeConfiguration>
            <discoverRuntimes>
              <product>EE</product>
              <includeSnapshots>true</includeSnapshots>
            </discoverRuntimes>
          </runtimeConfiguration>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.mule.connectors</groupId>
            <artifactId>mule-http-connector</artifactId>
            <classifier>mule-plugin</classifier>
            <version>1.9.2</version>
          </dependency>
          <dependency>
            <groupId>68ef9520-24e9-4cf2-b2f5-620025690913</groupId>
            <artifactId>books-api</artifactId>
            <version>1.0.0</version>
            <!-- graphql classifier not supported by region-classloader -->
            <classifier>graphql</classifier>
            <type>zip</type>
          </dependency>
        </dependencies>
      </plugin>


      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.7.9</version>
        <executions>
          <execution>
            <id>pre-unit-test</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>post-unit-test</id>
            <goals>
              <goal>report</goal>
            </goals>
            <phase>test</phase>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <repositories>
    <repository>
      <id>mulesoft-maven-all</id>
      <name>Mulesoft Maven All</name>
      <url>https://nexus-proxy.repo.local.sfdc.net/nexus/content/repositories/mulesoft-maven-all/</url>
    </repository>
    <repository>
      <id>maven2-proxy-msp-n3builds</id>
      <name>Maven2 Proxy MSP n3 Builds</name>
      <url>https://nexus-proxy.repo.local.sfdc.net/nexus/repository/maven2-proxy-msp-n3builds/</url>
    </repository>
    <repository>
      <id>studio</id>
      <name>Studio build repositories</name>
      <url>https://repository.mulesoft.org/nexus/content/groups/studio</url>
    </repository>

    <repository>
      <id>mule-private</id>
      <name>Mule Repository</name>
      <url>https://repository.mulesoft.org/nexus/content/repositories/private/</url>
    </repository>

  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>studio</id>
      <name>Studio build repositories</name>
      <url>https://repository.mulesoft.org/nexus/content/groups/studio</url>
    </pluginRepository>
    <pluginRepository>
      <id>mule-plugin</id>
      <name>Mule Repository</name>
      <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
    </pluginRepository>

    <!--
    MTF generated application will fetch the dependencies from pluginRepositories definitions
    doing this MTF will find our local artifacts,
    simulating we fetch the assets from exchange
    -->
    <pluginRepository>
      <id>local-exchange</id>
      <url>file://${project.basedir}/src/test/resources/exchange</url>
    </pluginRepository>
    <pluginRepository>
      <id>mulesoft-maven-all</id>
      <name>Mulesoft Maven All</name>
      <url>https://nexus-proxy.repo.local.sfdc.net/nexus/content/repositories/mulesoft-maven-all/</url>
    </pluginRepository>
    <pluginRepository>
      <id>maven2-proxy-msp-n3builds</id>
      <name>Maven2 Proxy MSP n3 Builds</name>
      <url>https://nexus-proxy.repo.local.sfdc.net/nexus/repository/maven2-proxy-msp-n3builds/</url>
    </pluginRepository>

    <pluginRepository>
      <id>mule-private</id>
      <name>Mule Repository</name>
      <url>https://repository.mulesoft.org/nexus/content/repositories/private/</url>
    </pluginRepository>

  </pluginRepositories>

  <profiles>
    <profile>
      <id>release-sfci</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <!-- Addition-3 (W-23624366): the INTERNAL deploy skip marker is loaded ONLY
               under this profile. -Prelease-sfci is the sole differentiator between the
               internal deploy (uses it) and the public deploy (does not), so scoping the
               marker here binds the internal skip signal to the internal deploy and
               prevents it from leaking into the public deploy. -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0.0</version>
            <executions>
              <execution>
                <id>sfci-check-internal-deploy-skip</id>
                <phase>validate</phase>
                <goals>
                  <goal>read-project-properties</goal>
                </goals>
                <configuration>
                  <quiet>true</quiet>
                  <files>
                    <file>${project.basedir}/.sfci-internal-deploy-skip.properties</file>
                  </files>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <distributionManagement>
        <repository>
          <id>project</id>
          <name>SFCI Internal Releases</name>
          <url>${env.NEXUS_BASE_URL}/repositories/releases/</url>
        </repository>
        <snapshotRepository>
          <id>project</id>
          <name>SFCI Internal Snapshots</name>
          <url>${env.NEXUS_BASE_URL}/repositories/snapshots/</url>
        </snapshotRepository>
      </distributionManagement>
    </profile>
  </profiles>

  <!-- W-23624366 (Addition-2) / W-23230021: TOP-LEVEL distributionManagement for
       the PUBLIC prod MuleSoft Nexus deploy (the `maven-publish` + `mulesoft-nexus:
       true` step, separate from the release-sfci internal deploy above). Declared
       explicitly so the public deploy — and check-deploy-skip.sh's public probe,
       which resolves project.distributionManagement.repository.url — target the
       real public repo rather than silently falling back to whatever the parent
       POM declares. Credentials already exist in the shared settings.xml (server
       ids mule-releases / mule-ee-snapshots, MULESOFT_PUBLIC_NEXUS_*_RW). -->
  <distributionManagement>
    <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-ee-snapshots</id>
      <name>Mule Snapshot Repository</name>
      <url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-snapshots</url>
      <uniqueVersion>false</uniqueVersion>
    </snapshotRepository>
  </distributionManagement>

</project>
