<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
    <artifactId>mule-tracing-module</artifactId>
    <packaging>mule-extension</packaging>
    <name>Mule Tracing Module</name>
    <description>Mule module for traceability features, including customizable MDC and CorrelationID</description>

    <parent>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-tracing-module-parent</artifactId>
        <version>1.2.1</version>
    </parent>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <formatterConfigPath>../formatter.xml</formatterConfigPath>

        <!-- Override the versions from the parent for using a more recent packager and annotations processor -->
        <java.release.version>8</java.release.version>
        <mule.extensions.support.version>4.6.26</mule.extensions.support.version>
        <mule.extensions.maven.plugin.version>1.9.12</mule.extensions.maven.plugin.version>
        <mule.extensions.ast.loader.version>1.8.13</mule.extensions.ast.loader.version>
        <extensionsAnnotationProcessorCompileProc></extensionsAnnotationProcessorCompileProc>
        <extensionsAnnotationProcessor>
            org.mule.runtime.ast.extension.api.loader.ASTExtensionResourcesGeneratorAnnotationProcessor
        </extensionsAnnotationProcessor>
        <exportedPackagesValidator.skip>false</exportedPackagesValidator.skip>
        <exportedPackagesValidator.strictValidation>false</exportedPackagesValidator.strictValidation>
        <mule.sdk.api.version>1.0.0</mule.sdk.api.version>
        <!-- / -->

        <munit.extensions.maven.plugin.version>1.7.1-rc1</munit.extensions.maven.plugin.version>
        <munit.version>3.7.1-rc1</munit.version>
        <mtf-tools.version>1.3.0-rc3</mtf-tools.version>
        <munitMinMuleVersion>4.6.0</munitMinMuleVersion>

        <junit.jupiter.version>5.14.3</junit.jupiter.version>
        <mockito.version>4.11.0</mockito.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${junit.jupiter.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-module-extensions-support</artifactId>
            <version>${mule.extensions.support.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.sdk</groupId>
            <artifactId>mule-sdk-api</artifactId>
            <version>${mule.sdk.api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <encoding>ISO-8859-1</encoding>
                        <release>${java.release.version}</release>
                        <proc>${extensionsAnnotationProcessorCompileProc}</proc>
                        <parameters>true</parameters>
                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.mule.runtime</groupId>
                                <artifactId>mule-extension-ast-loader</artifactId>
                                <version>${mule.extensions.ast.loader.version}</version>
                            </path>
                            <path>
                                <groupId>org.mule.runtime</groupId>
                                <artifactId>mule-module-extensions-spring-support</artifactId>
                                <version>${mule.extensions.support.version}</version>
                            </path>
                        </annotationProcessorPaths>
                        <annotationProcessors>
                            <annotationProcessors>${extensionsAnnotationProcessor}</annotationProcessors>
                        </annotationProcessors>
                        <compilerArgs>
                            <arg>-Aextension.version=${project.version}</arg>
                            <arg>-Aextension.resources=${project.build.resources[0].directory}</arg>
                            <arg>-AexportedPackagesValidator.skip=${exportedPackagesValidator.skip}</arg>
                            <arg>-AexportedPackagesValidator.strictValidation=${exportedPackagesValidator.strictValidation}</arg>
                        </compilerArgs>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.mule.sdk</groupId>
                            <artifactId>mule-sdk-api</artifactId>
                            <version>${mule.sdk.api.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <!-- Add Target-Java-Release-Version, not set bu the parent configuration but needed by the packager -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <archive>
                            <!--
                                Disabled for http://mule.mulesoft.org/jira/browse/MULE-1153
                                and http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4408526
                             -->
                            <index>false</index>
                            <!-- List dependencies in the MANIFEST.MF -->
                            <manifest>
                                <!-- Note that we do not generate a classpath into the manifest, since doing so
                                     significnatly slows down compilations that use the jar -->
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            </manifest>
                            <manifestEntries>
                                <Build-Date>${maven.build.timestamp}</Build-Date>
                                <!-- Custom Entries -->
                                <Target-Java-Release-Version>${java.release.version}</Target-Java-Release-Version>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- Disable this plugin, as annotation processor is configured on the compiler plugin now -->
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <executions>
                    <execution>
                        <id>process</id>
                        <phase>none</phase>
                    </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>
                            -XX:+IgnoreUnrecognizedVMOptions
                        </argLine>
                        <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>

                    <!-- Configuration for local builds, in Jenkins we configure this via command line arguments -->
                    <runtimeConfiguration>
                        <!-- Versions with support and snapshots -->
                        <discoverRuntimes>
                            <product>EE</product>
                            <minMuleVersion>${munitMinMuleVersion}</minMuleVersion>
                            <includeSnapshots>true</includeSnapshots>
                            <latestPatches>true</latestPatches>
                        </discoverRuntimes>
                    </runtimeConfiguration>
                </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>
        </plugins>
    </build>
</project>
