<?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-core-modules-parent</artifactId>
        <version>1.6.23</version>
    </parent>

    <groupId>com.mulesoft.munit</groupId>
    <artifactId>munit-tools</artifactId>
    <version>3.6.2</version>
    <packaging>mule-extension</packaging>

    <name>MUnit :: Tools Extension</name>
    <description>SDK based Mule plugin defining the DSL for assertion and mock processors</description>

    <properties>
        <mule.api.version>1.6.0</mule.api.version>
        <commons.lang3.version>3.19.0</commons.lang3.version>
        <weave.assertions.version>1.0.2</weave.assertions.version>
        <jakarta.activation.version>1.2.2</jakarta.activation.version>
        <mule.os.connector.version>1.1.3</mule.os.connector.version>
        <commons.io.version>2.17.0</commons.io.version>
        <mockito.version>4.11.0</mockito.version>
        <mule.sdk.api.version>0.11.4</mule.sdk.api.version>
        <!-- Plugin Versions -->
        <spotbugs.maven.plugin.version>4.7.2.1</spotbugs.maven.plugin.version>
        <checkstyle.plugin.version>2.17</checkstyle.plugin.version>
        <checkstyle.version>8.0</checkstyle.version>
        <javaFormatter.plugin.version>2.0.1</javaFormatter.plugin.version>
        <license.maven.plugin.version>3.0</license.maven.plugin.version>
        <maven.javadoc.plugin.version>3.2.0</maven.javadoc.plugin.version>
        <maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>

        <licensePath>../../LICENSE_HEADER.txt</licensePath>
        <formatterConfigPath>../../formatter.xml</formatterConfigPath>
        <spotbugsExcludePath>../../findbugs-exclude.xml</spotbugsExcludePath>

        <jacoco.maven.plugin.version>0.8.10</jacoco.maven.plugin.version>
        <jacoco.report.location>${project.build.directory}/jacoco.exec</jacoco.report.location>
        <coverageLineLimit>0.70</coverageLineLimit>
        <coverageBranchLimit>0.70</coverageBranchLimit>
        <skipTests>false</skipTests>
        <skipJaCoCoCoverage>false</skipJaCoCoCoverage>

    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.1.2</version>
                <configuration>
                    <argLine>
                        -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.maven.plugin.version}/org.jacoco.agent-${jacoco.maven.plugin.version}-runtime.jar=destfile=${project.build.directory}/jacoco.exec
                    </argLine>
                    <skipTests>${skipTests}</skipTests>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.maven.plugin.version}</version>
                <executions>
                    <!-- Attach JaCoCo Agent Before Running Tests -->
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco.exec</destFile>
                            <append>true</append>
                        </configuration>
                    </execution>

                    <!-- Generate JaCoCo Report -->
                    <execution>
                        <id>report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>

                    <!-- Check Code Coverage -->
                    <execution>
                        <id>check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>${coverageLineLimit}</minimum>
                                        </limit>
                                        <limit>
                                            <counter>BRANCH</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>${coverageBranchLimit}</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>





            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M3</version>
                <executions>
                    <execution>
                        <id>enforce-no-snapshots</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireReleaseDeps>
                                    <message>No Snapshots Allowed!</message>
                                    <onlyWhenRelease>true</onlyWhenRelease>
                                </requireReleaseDeps>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${license.maven.plugin.version}</version>
                <configuration>
                    <header>${licensePath}</header>
                    <excludes>
                        <exclude>target/**</exclude>
                        <exclude>**/.gitignore</exclude>
                        <exclude>**/*.txt</exclude>
                        <exclude>**/*.groovy</exclude>
                        <exclude>**/*.sh</exclude>
                        <exclude>**/*.bat</exclude>
                        <exclude>**/*.ftl</exclude>
                        <exclude>**/*.xml</exclude>
                        <exclude>**/*.properties</exclude>
                        <exclude>**/*.sample</exclude>
                        <exclude>**/*.md</exclude>
                        <exclude>**/*.xsl</exclude>
                        <exclude>**/*.html</exclude>
                        <exclude>**/*.css</exclude>
                    </excludes>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <mapping>
                        <java>SLASHSTAR_STYLE</java>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${checkstyle.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>${checkstyle.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <skip>${skipVerifications}</skip>
                    <configLocation>../../munit_check.xml</configLocation>
                    <failOnViolation>true</failOnViolation>
                </configuration>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                            <goal>checkstyle-aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>${spotbugs.maven.plugin.version}</version>
                <configuration>
                    <xmlOutput>true</xmlOutput>
                    <threshold>High</threshold>
                    <skip>${skipVerifications}</skip>
                    <failOnError>true</failOnError>
                    <excludeFilterFile>${spotbugsExcludePath}</excludeFilterFile>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>spotbugs</goal>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--  This should be Removed when SDK update munit-extensions-maven-plugin to 1.2.0 -->
            <plugin>
                <groupId>com.mulesoft.munit</groupId>
                <artifactId>munit-extensions-maven-plugin</artifactId>
                <version>1.2.0</version>
                <dependencies>
                    <!-- MUnit 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>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>${spotbugs.maven.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${checkstyle.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.maven.plugin.version}</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>report</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-compress</artifactId>
            <version>1.26.2</version>
        </dependency>
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.4.01</version>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.munit</groupId>
            <artifactId>munit-assert</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.munit</groupId>
            <artifactId>munit-mock</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.munit</groupId>
            <artifactId>munit-runner</artifactId>
            <version>${project.version}</version>
            <classifier>mule-plugin</classifier>
            <exclusions>
                <exclusion>
                    <groupId>com.mulesoft.munit</groupId>
                    <artifactId>munit-maven-plugins-common</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mule.weave</groupId>
            <artifactId>assertions</artifactId>
            <version>${weave.assertions.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons.lang3.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.activation</groupId>
            <artifactId>jakarta.activation</artifactId>
            <version>${jakarta.activation.version}</version>
        </dependency>

        <!--TODO Workaround for MULE-11650-->
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-core</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>asm</groupId>
                    <artifactId>asm</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-io</groupId>
                    <artifactId>commons-io</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-collections</groupId>
                    <artifactId>commons-collections</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.9</version>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <groupId>org.mule.sdk</groupId>
            <artifactId>mule-sdk-api</artifactId>
            <version>${mule.sdk.api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.mule.connectors</groupId>
            <artifactId>mule-objectstore-connector</artifactId>
            <version>${mule.os.connector.version}</version>
            <classifier>mule-plugin</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-inline</artifactId>
            <version>${mockito.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>


    <distributionManagement>
        <repository>
            <id>mule-releases</id>
            <name>MuleSoft Releases Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-releases</url>
        </repository>
        <snapshotRepository>
            <id>mule-snapshots</id>
            <name>MuleSoft Snapshots Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <distributionManagement>
                <repository>
                    <id>mule-releases</id>
                    <name>MuleSoft Releases Repository</name>
                    <url>https://repository-master.mulesoft.org/releases/</url>
                </repository>
            </distributionManagement>
        </profile>
        <profile>
            <id>release-sfci</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <distributionManagement>
                <repository>
                    <id>project</id>
                    <name>SFCI Internal Releases</name>
                    <url>${NEXUS_BASE_URL}/repositories/releases/</url>
                </repository>
                <snapshotRepository>
                    <id>project</id>
                    <name>SFCI internal Snapshots</name>
                    <url>${NEXUS_BASE_URL}/repositories/snapshots/</url>
                </snapshotRepository>
            </distributionManagement>
        </profile>
        <profile>
            <id>java-17</id>
            <activation>
                <jdk>[17,21]</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                        <configuration>
                            <excludes>
                                <exclude>**/com/example/**/*Test.java</exclude>
                                <exclude>**/org/mule/munit/tools/**/*Test.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
