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

    <groupId>com.mulesoft.connectors</groupId>
    <artifactId>mule-azure-key-vault-client</artifactId>
    <version>1.2.3</version>

    <properties>
        <!-- Java Compatibility -->
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <javaVersion>1.8</javaVersion>

        <!-- Azure SDK Dependencies -->
        <!-- W-20005674: Locked to 1.2.35 to avoid internal API breakage and manage vulnerabilities via exclusions -->
        <azure.sdk.bom.version>1.2.35</azure.sdk.bom.version>
        
        <!-- Netty Version Management -->
        <!-- W-20005674: Explicit versions to address CVEs without upgrading azure-sdk-bom -->
        <netty.version>4.1.128.Final</netty.version>
        <reactor.netty.http.version>1.2.11</reactor.netty.http.version>
        
        <!-- Security & Authentication -->
        <json.smart.version>2.6.0</json.smart.version>
        <nimbus.jose.jwt.version>10.5</nimbus.jose.jwt.version>
        <fasterxml.jackson.version>2.20.0</fasterxml.jackson.version>
        
        <!-- Testing -->
        <mockito.version>4.6.1</mockito.version>
        <junit-jupiter-params.version>5.7.0</junit-jupiter-params.version>
        
        <!-- Build Plugins -->
        <maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
        <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
        <javaFormatter.plugin.version>2.16.0</javaFormatter.plugin.version>
        <connector.maven.plugin.version>3.0.2</connector.maven.plugin.version>
        
        <!-- Build Configuration -->
        <formatterGoal>validate</formatterGoal>
        <skipVerifications>false</skipVerifications>
        <formatterConfigPath>formatter.xml</formatterConfigPath>
        <configuration.files.s3.folder>mule-azure-key-vault-connector</configuration.files.s3.folder>
        <configuration.files.vault.secret.engine>connector-credentials</configuration.files.vault.secret.engine>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.mulesoft.connectors.maven</groupId>
                <artifactId>connector-maven-plugin</artifactId>
                <version>${connector.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>get-configuration-files</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>get-configuration-files</goal>
                        </goals>
                        <configuration>
                            <folder>${configuration.files.s3.folder}</folder>
                            <vaultBucket>${configuration.files.vault.secret.engine}</vaultBucket>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipTests>${skipTests}</skipTests>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <skipTests>${skipTests}</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>prepare-agent-ut</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>prepare-agent-it</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-report-ut</id>
                        <phase>test</phase> <!-- need to override the xml report generation for unit tests from verify to test phase -->
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-report-it</id>
                        <goals>
                            <goal>report-integration</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- Formatter plugin -->
            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
                <version>${javaFormatter.plugin.version}</version>
                <configuration>
                    <compilerCompliance>${javaVersion}</compilerCompliance>
                    <compilerSource>${javaVersion}</compilerSource>
                    <compilerTargetPlatform>${javaVersion}</compilerTargetPlatform>
                    <configFile>${basedir}/${formatterConfigPath}</configFile>
                    <configJsFile>${basedir}/${formatterConfigPath}</configJsFile>
                    <aggregator>false</aggregator>
                    <executionRoot>true</executionRoot>
                    <encoding>UTF-8</encoding>
                </configuration>
                <executions>
                    <execution>
                        <id>apply-format</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>${formatterGoal}</goal>
                        </goals>
                        <configuration>
                            <skipFormatting>${skipVerifications}</skipFormatting>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <!-- Azure SDK BOM: Manages all Azure SDK versions -->
            <dependency>
                <groupId>com.azure</groupId>
                <artifactId>azure-sdk-bom</artifactId>
                <version>${azure.sdk.bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            
            <!-- Netty BOM: Enforces consistent Netty version across all transitive dependencies -->
            <!-- W-20005674: Required to patch vulnerabilities without upgrading azure-sdk-bom -->
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-bom</artifactId>
                <version>${netty.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Azure Key Vault SDK Dependencies         -->
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-security-keyvault-secrets</artifactId>
            <exclusions>
                <!-- Use explicit version for security compliance -->
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <!-- W-20005674: Exclude to use patched versions via netty-bom for CVE fixes -->
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-handler</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.projectreactor.netty</groupId>
                    <artifactId>reactor-netty-http</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-security-keyvault-certificates</artifactId>
        </dependency>
        
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-security-keyvault-keys</artifactId>
        </dependency>

        <!-- Azure Identity & Authentication          -->
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-identity</artifactId>
            <exclusions>
                <!-- W-20005674: Exclude to use explicit versions for CVE fixes and FIPS compliance -->
                <exclusion>
                    <groupId>net.minidev</groupId>
                    <artifactId>json-smart</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.nimbusds</groupId>
                    <artifactId>nimbus-jose-jwt</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <!-- Explicit versions for security & FIPS compliance -->
        <dependency>
            <groupId>net.minidev</groupId>
            <artifactId>json-smart</artifactId>
            <version>${json.smart.version}</version>
        </dependency>
        
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>${nimbus.jose.jwt.version}</version>
        </dependency>
        
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${fasterxml.jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>io.projectreactor.netty</groupId>
            <artifactId>reactor-netty-http</artifactId>
            <version>${reactor.netty.http.version}</version>
        </dependency>
        
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
        </dependency>
        
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec</artifactId>
        </dependency>

        <!-- Required for FIPS build on pipeline -->
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-properties-api</artifactId>
            <version>1.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-inline</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit-jupiter-params.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <scm>
        <connection>scm:git:git://github.com:mulesoft/mule4-azure-keyvault-connector-client.git</connection>
        <developerConnection>scm:git:git@github.com:mulesoft/mule4-azure-keyvault-connector-client.git</developerConnection>
        <url>http://github.com/mulesoft/mule4-azure-keyvault-connector-client</url>
        <tag>HEAD</tag>
    </scm>
</project>
