<?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-odata-module</artifactId>
    <version>1.6.3</version>
    <packaging>mule-extension</packaging>

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

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <javaFormatter.plugin.version>2.16.0</javaFormatter.plugin.version>
        <olingo.version>4.9.0</olingo.version>
        <mule.weave.version>2.6.1</mule.weave.version>
        <jackson.databind.version>2.21.8</jackson.databind.version>
        <jackson.version>2.21.8</jackson.version>
        <jackson.annotations.version>2.21</jackson.annotations.version>
        <jacoco.version>0.8.14</jacoco.version>
        <mockito-junit-jupiter.version>4.11.0</mockito-junit-jupiter.version>
        <mockito-core.version>4.11.0</mockito-core.version>
        <junit-jupiter.version>5.9.3</junit-jupiter.version>
        <sdk-api.version>0.9.3</sdk-api.version>
        <byte-buddy.version>1.17.5</byte-buddy.version>

        <!-- Munit properties -->
        <!-- 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-385 build #2). All bumps below are test/build scope only; the
             shipped mule-plugin artifact's runtime dependencies are unchanged. -->
        <munit.extensions.maven.plugin.version>1.7.3</munit.extensions.maven.plugin.version>
        <munit.version>3.7.5</munit.version>
        <mtf-tools.version>1.3.0-rc3</mtf-tools.version>

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

    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.20.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.18.0</version>
            </dependency>
            <!-- W-23230021-W-23230022: pin byte-buddy to a JDK 17-capable version so the
                 test JVM (mockito 4.11.0 pulls an older byte-buddy transitively) can
                 instrument classes on the derived JDK 17 lanes. Test/build scope only. -->
            <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>org.apache.olingo</groupId>
            <artifactId>odata-client-api</artifactId>
            <version>${olingo.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpclient</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mule.sdk</groupId>
            <artifactId>mule-sdk-api</artifactId>
            <version>${sdk-api.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.olingo</groupId>
            <artifactId>odata-client-core</artifactId>
            <version>${olingo.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpclient</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.dataformat</groupId>
                    <artifactId>jackson-dataformat-xml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.olingo</groupId>
            <artifactId>odata-server-core</artifactId>
            <version>${olingo.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec-http</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>jackson-core</artifactId>
                    <groupId>com.fasterxml.jackson.core</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.olingo</groupId>
            <artifactId>odata-server-core-ext</artifactId>
            <version>${olingo.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.databind.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.annotations.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <!-- W-24870025 / W-24870027: depMgmt alone is dropped when this module is
             packaged as a mule-plugin, so Olingo 4.9.0 still ships commons-io 2.11.0
             and commons-lang3 3.12.0. Direct deps are what land in classloader-model.json. -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.20.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.18.0</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.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit-jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit-jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito-core.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.sdk</groupId>
            <artifactId>mule-sdk-compatibility-api</artifactId>
            <version>${muleSdkCompatibilityApiVersion}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.mule.sdk</groupId>
                    <artifactId>mule-sdk-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <!-- Addition-2, W-23624366: TOP-LEVEL distributionManagement for the PUBLIC prod
         MuleSoft Nexus deploy (the `mulesoft-nexus: true` maven-publish step in
         .strata.yml, separate from the release-sfci profile's internal deploy below).
         Without this, the deploy falls back to whatever the POM's parent
         (mule-ee-core-modules-parent) declares, which is the internal ci-releases
         repo (id mule-ee-releases) — not the public prod repo customers pull from.
         Credentials already exist in the shared settings.xml (server ids
         mule-releases / mule-ee-snapshots, MULESOFT_PUBLIC_NEXUS_*_RW) — no new
         servers needed. -->
    <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>

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


    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>net.revelc.code.formatter</groupId>
                    <artifactId>formatter-maven-plugin</artifactId>
                    <configuration>
                        <lineEnding>LF</lineEnding>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <!-- 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). -->
            <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>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </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>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <!-- Profile for SFCI Internal Nexus (used by first maven-publish step) -->
    <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>

</project>
