<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.mule.extensions</groupId>
        <artifactId>mule-modules-parent</artifactId>
        <version>1.2.1</version>
    </parent>
    <groupId>com.mulesoft.connectors</groupId>
    <artifactId>mule4-connectors-parent</artifactId>
    <version>2.0.0</version>
    <packaging>pom</packaging>
    <name>Mule Connectivity Parent POM</name>

    <properties>
        <jdk.version>1.8</jdk.version>

        <mule.sdk.api.version>0.10.1</mule.sdk.api.version>
        <mule.connector.commons.version>2.1.1</mule.connector.commons.version>

        <configuration.files.vault.secret.engine>connector-credentials</configuration.files.vault.secret.engine>
        <configuration.files.s3.folder>${project.artifactId}</configuration.files.s3.folder>

        <jacoco.version>0.8.10</jacoco.version>
        <munit.extensions.maven.plugin.version>1.1.2</munit.extensions.maven.plugin.version>
        <munit.version>2.2.4</munit.version>
        <mtf.tools.version>1.1.2</mtf.tools.version>
        <munit.input.directory>src/test/munit</munit.input.directory>
        <munit.output.directory>${basedir}/target/test-mule/munit</munit.output.directory>

        <maven.enforcer.plugin.version>3.4.1</maven.enforcer.plugin.version>
        <maven.resources.plugin.version>3.3.1</maven.resources.plugin.version>
        <maven.failsafe.plugin.version>3.2.5</maven.failsafe.plugin.version>
        <maven.dependency.plugin.version>3.6.1</maven.dependency.plugin.version>
        <maven.jdeps.plugin.version>3.1.2</maven.jdeps.plugin.version>

        <javaFormatter.plugin.version>2.14.0</javaFormatter.plugin.version>
        <formatterConfigPath>formatter.xml</formatterConfigPath>
        <formatterGoal>validate</formatterGoal>

        <importGoal>check</importGoal>
        <maven.checkstyle.plugin.version>3.3.1</maven.checkstyle.plugin.version>
        <maven.impsort.plugin.version>1.6.2</maven.impsort.plugin.version>

        <skipVerifications>false</skipVerifications>
        <exportedPackagesValidator.strictValidation>true</exportedPackagesValidator.strictValidation>

<!--        Sarting with mule 4.5 -->
<!--        <muleBomVersion>4.5.1-SNAPSHOT</muleBomVersion>-->

        <mulesoftLicenseVersion>1.4.0</mulesoftLicenseVersion>
        <license.maven.plugin.version>4.2</license.maven.plugin.version>
        <licenseYear>2023</licenseYear>
        <licensePluginGoal>check</licensePluginGoal>

        <directory>${project.basedir}/target</directory>
        <aspectjVersion>1.9.2</aspectjVersion>
        <allureJunitVersion>2.8.1</allureJunitVersion>
        <allureReportVersion>2.8.1</allureReportVersion>
        <allure.maven.plugin.version>2.9</allure.maven.plugin.version>


    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Commons dependency that could be used in all the connectors that extend this pom. -->
            <dependency>
                <groupId>com.mulesoft.connectors</groupId>
                <artifactId>mule-connector-commons</artifactId>
                <version>${mule.connector.commons.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.mule.runtime</groupId>
                        <artifactId>mule-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.mule.runtime</groupId>
                        <artifactId>mule-extensions-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.mule.sdk</groupId>
            <artifactId>mule-sdk-api</artifactId>
            <version>${mule.sdk.api.version}</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin> <!-- Who needs this thing?? -->
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${maven.resources.plugin.version}</version>
                    <executions>
                        <execution>
                            <id>copy-munit-resources</id>
                            <phase>process-test-resources</phase>
                            <goals>
                                <goal>copy-resources</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${munit.output.directory}</outputDirectory>
                                <resources>
                                    <resource>
                                        <directory>${munit.input.directory}</directory>
                                        <filtering>true</filtering>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <argLine>-Dfile.encoding=UTF-8 -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectjVersion}/aspectjweaver-${aspectjVersion}.jar -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile='${session.executionRootDirectory}/target/jacoco.exec'</argLine>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>io.qameta.allure.junit4.AllureJunit4</value>
                            </property>
                        </properties>
                        <systemPropertyVariables>
                            <!-- Just propagate this variable due to surefire will not do this when forked vm for tests -->
                            <mule.freePortFinder.lockPath>${java.io.tmpdir}/mule/freePortFinder</mule.freePortFinder.lockPath>
                            <maven.projectVersion>${project.version}</maven.projectVersion>
                        </systemPropertyVariables>
                        <systemProperties>
                            <property>
                                <name>allure.results.directory</name>
                                <value>${project.build.directory}/allure-results</value>
                            </property>
                        </systemProperties>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjweaver</artifactId>
                            <version>${aspectjVersion}</version>
                        </dependency>
                        <dependency>
                            <groupId>org.jacoco</groupId>
                            <artifactId>org.jacoco.agent</artifactId>
                            <version>${jacoco.version}</version>
                            <classifier>runtime</classifier>
                        </dependency>
                    </dependencies>
                </plugin>

                <plugin>
                    <groupId>io.qameta.allure</groupId>
                    <artifactId>allure-maven</artifactId>
                    <version>${allure.maven.plugin.version}</version>
                    <configuration>
                        <reportVersion>${allureReportVersion}</reportVersion>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>com.mulesoft.munit</groupId>
                <artifactId>munit-extensions-maven-plugin</artifactId>
                <version>${munit.extensions.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skipAfterFailure>true</skipAfterFailure>
                    <argLines>
                        <argLine>
                            -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${session.executionRootDirectory}/target/jacoco-munit.exec
                        </argLine>
                    </argLines>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>munit-runner</artifactId>
                        <version>${munit.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>munit-tools</artifactId>
                        <version>${munit.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>mtf-tools</artifactId>
                        <version>${mtf.tools.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <configuration>
                    <destFile>${session.executionRootDirectory}/target/jacoco-java.exec</destFile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>merge</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>merge</goal>
                        </goals>
                        <configuration>
                            <destFile>${session.executionRootDirectory}/target/jacoco.exec</destFile>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>*.exec</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- ## Plugin included to add Integration Tests (IT) to the build lifecycle.
            The Failsafe Plugin is used during the `integration-test` and `verify` phases of the build
            lifecycle to execute the integration tests of an application. The Failsafe Plugin will not
            fail the build during the integration-test phase, thus enabling the post-integration-test
            phase to execute.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven.failsafe.plugin.version}</version>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Plugin added to make sure that all dependencies that are declared are used. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${maven.dependency.plugin.version}</version>
                <executions>
                    <execution>
                        <id>connector-analyze</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>analyze-only</goal>
                        </goals>
                        <configuration>
                            <ignoredDependencies>
                                <ignoredDependency>org.mule.*</ignoredDependency>
                                <ignoredDependency>com.sun.mail:jakarta.mail</ignoredDependency>
                            </ignoredDependencies>
                            <failOnWarning>true</failOnWarning>
                            <ignoredUsedUndeclaredDependencies>
                                <ignoredUsedUndeclaredDependency>*</ignoredUsedUndeclaredDependency>
                            </ignoredUsedUndeclaredDependencies>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Plugin added to enforce the compliance with several rules. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${maven.enforcer.plugin.version}</version>
                <executions>
                    <execution>
                        <id>default-enforced-rules</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <banDistributionManagement />
                                <requireNoRepositories>
                                    <allowedRepositories>
                                        <!-- This is a repository provided by this pom's parent. -->
                                        <allowedRepository>mule</allowedRepository>
                                        <allowedRepository>mule-releases</allowedRepository>
                                    </allowedRepositories>
                                    <allowedPluginRepositories>
                                        <!-- These are repositories provided by this pom's parent. -->
                                        <allowedPluginRepository>mulesoft-plugin-releases</allowedPluginRepository>
                                        <allowedPluginRepository>mulesoft-plugin-snapshots</allowedPluginRepository>
                                    </allowedPluginRepositories>
                                </requireNoRepositories>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
                <version>${javaFormatter.plugin.version}</version>
                <configuration>
                    <compilerCompliance>${jdk.version}</compilerCompliance>
                    <compilerSource>${jdk.version}</compilerSource>
                    <compilerTargetPlatform>${jdk.version}</compilerTargetPlatform>
                    <configFile>${basedir}/${formatterConfigPath}</configFile>
                    <configJsFile>${basedir}/${formatterConfigPath}</configJsFile>
                    <aggregator>false</aggregator>
                    <executionRoot>true</executionRoot>
                </configuration>
                <executions>
                    <execution>
                        <id>apply-format</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>${formatterGoal}</goal>
                        </goals>
                        <configuration>
                            <skipFormatting>${skipVerifications}</skipFormatting>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.revelc.code</groupId>
                <artifactId>impsort-maven-plugin</artifactId>
                <version>${maven.impsort.plugin.version}</version>
                <configuration>
                    <groups>org.mule.,com.mulesoft.,java.,javax.</groups>
                    <staticGroups>org.mule.,com.mulesoft.,java.,javax.</staticGroups>
                </configuration>
                <executions>
                    <execution>
                        <id>validate-imports</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>${importGoal}</goal>
                        </goals>
                        <configuration>
                            <skip>${skipVerifications}</skip>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <!-- Needed because of maven 3.9.0 backward compatibility issue,
                         See : https://github.com/eclipse/leshan/issues/1410 -->
                    <dependency>
                        <groupId>org.codehaus.plexus</groupId>
                        <artifactId>plexus-utils</artifactId>
                        <version>3.5.1</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${maven.checkstyle.plugin.version}</version>
                <executions>
                    <execution>
                        <id>verify-style</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skip>${skipVerifications}</skip>
                    <logViolationsToConsole>true</logViolationsToConsole>
                    <checkstyleRules>
                        <module name="Checker">
                            <module name="TreeWalker">
                                <module name="AvoidStarImport"/>
                                <module name="UnusedImports" />
                            </module>
                        </module>
                    </checkstyleRules>
                </configuration>
            </plugin>

            <!-- Added since Java 17 - FY24 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jdeps-plugin</artifactId>
                <version>${maven.jdeps.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jdkinternals</goal> <!-- verify main classes -->
                            <goal>test-jdkinternals</goal> <!-- verify test classes -->
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <failOnWarning>true</failOnWarning>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <scm>
        <connection>scm:git:git@github.com:mulesoft/${project.artifactId}.git</connection>
        <developerConnection>scm:git:git@github.com:mulesoft/${project.artifactId}.git</developerConnection>
        <url>https://github.com/mulesoft/${project.artifactId}</url>
    </scm>

    <profiles>
        <!-- Profile to enforce that versions deployed to release servers don't have SNAPSHOT. -->
        <profile>
            <id>release-deployer</id>
            <activation>
                <property>
                    <name>deployer.type</name>
                    <value>release</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>${maven.enforcer.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>version-enforced-rules</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireReleaseVersion />
                                        <requireReleaseDeps />
                                    </rules>
                                    <fail>true</fail>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
