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

    <groupId>com.mulesoft.connectivity</groupId>
    <artifactId>rest-connector-commons-parent-pom</artifactId>
    <version>0.0.5</version>
    <packaging>pom</packaging>

    <properties>
        <!-- Remove when new parent version upgrades log4j dependencies -->
        <log4j.version>2.17.2</log4j.version>

        <!-- Remove when a new parent version with MTF is available -->
        <munit-extensions-maven-plugin.version>1.1.2</munit-extensions-maven-plugin.version>
        <munit.version>2.3.9</munit.version>
        <mtf-tools.version>1.1.2</mtf-tools.version>
        <!-- End of remove -->

        <!-- Maven Plugins -->
        <mule-runtime-tooling-client.version>4.4.0</mule-runtime-tooling-client.version>
        <!-- W-11245480: MTS classloading issue -->
        <jaxb-api.version>2.3.1</jaxb-api.version>
        <jaxb-impl.version>2.3.1-MULE-001</jaxb-impl.version>
        <!-- End of W-11245480 -->
        <!-- End of Maven Plugins -->

        <jacoco.version>0.8.7</jacoco.version>
        <mule.service.http.version>1.6.6</mule.service.http.version>
        <mule.service.scheduler.version>1.4.2</mule.service.scheduler.version>
        <muleSdkApiVersion>0.3.0</muleSdkApiVersion>
        <javaModule.version>1.2.5</javaModule.version>
        <data.weave.testing.framework.version>1.1.1</data.weave.testing.framework.version>
        <data.weave.maven.plugin.version>0.2.0</data.weave.maven.plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.mulesoft.connectivity</groupId>
            <artifactId>rest-connector-commons</artifactId>
            <version>0.0.5</version>
        </dependency>

        <!-- HTTP service dependencies -->
        <dependency>
            <groupId>org.mule.services</groupId>
            <artifactId>mule-service-http</artifactId>
            <version>${mule.service.http.version}</version>
            <classifier>mule-service</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.services</groupId>
            <artifactId>mule-service-scheduler</artifactId>
            <version>${mule.service.scheduler.version}</version>
            <classifier>mule-service</classifier>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>org.mule.module</groupId>
            <artifactId>mule-java-module</artifactId>
            <version>${javaModule.version}</version>
            <classifier>mule-plugin</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.weave</groupId>
            <artifactId>data-weave-testing-framework</artifactId>
            <version>${data.weave.testing.framework.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>${log4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>${log4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
                <version>${log4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-1.2-api</artifactId>
                <version>${log4j.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/dw</directory>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.8</version>
                    <executions>
                        <execution>
                            <id>unpack-mts-bundle</id>
                            <phase>package</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>org.mule.tooling</groupId>
                                        <artifactId>mule-runtime-tooling-client-bundle</artifactId>
                                        <version>${mule-runtime-tooling-client.version}</version>
                                        <type>zip</type>
                                        <classifier>zip</classifier>
                                        <overWrite>true</overWrite>
                                        <outputDirectory>${project.build.directory}/mts</outputDirectory>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                        <execution>
                            <!-- W-11245480: MTS classloading issue -->
                            <id>W-11245480</id>
                            <phase>package</phase>
                            <goals>
                                <goal>copy</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>javax.xml.bind</groupId>
                                        <artifactId>jaxb-api</artifactId>
                                        <version>${jaxb-api.version}</version>
                                        <overWrite>true</overWrite>
                                        <outputDirectory>${project.build.directory}/mts</outputDirectory>
                                    </artifactItem>
                                    <artifactItem>
                                        <groupId>com.sun.xml.bind</groupId>
                                        <artifactId>jaxb-impl</artifactId>
                                        <version>${jaxb-impl.version}</version>
                                        <overWrite>true</overWrite>
                                        <outputDirectory>${project.build.directory}/mts</outputDirectory>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                        <!-- End of W-11245480 -->
                    </executions>
                </plugin>

                <!-- W-11245480: MTS classloading issue -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>3.1.0</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <target>
                                    <delete file="${project.build.directory}/mts/jaxb-api-2.1.jar"/>
                                    <delete file="${project.build.directory}/mts/jaxb-impl-2.1.13.jar"/>
                                </target>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <!-- End of W-11245480 -->

                <plugin>
                    <groupId>com.mulesoft.connectivity</groupId>
                    <artifactId>citizen-platform-connectors-models-maven-plugin</artifactId>
                    <version>0.0.5</version>
                    <executions>
                        <execution>
                            <id>extension-model-generation</id>
                            <goals>
                                <goal>extension-model</goal>
                            </goals>
                            <configuration>
                                <mulePluginJarFile>${project.build.directory}/${project.artifactId}-${project.version}-mule-plugin.jar</mulePluginJarFile>
                                <toolingLibsFolder>${project.build.directory}/mts</toolingLibsFolder>
                            </configuration>
                        </execution>
                        <execution>
                            <id>connector-models-generation</id>
                            <goals>
                                <goal>connector-models-generator</goal>
                            </goals>
                            <configuration>
                                <!-- Exclude Mule/SDK synthetic parameters that should not go to the customization descriptor -->
                                <operationExcludeParameterNames>target,targetValue,errorMappings,reconnectionStrategy,streamingStrategy</operationExcludeParameterNames>
                                <sourceExcludeParameterNames>schedulingStrategy,primaryNodeOnly,streamingStrategy</sourceExcludeParameterNames>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>com.mulesoft.connectivity</groupId>
                    <artifactId>rest-connector-commons-exported-packages-maven-plugin</artifactId>
                    <version>0.0.5</version>
                    <executions>
                        <execution>
                            <id>validate-exported-packages</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>ValidateExportedPackages</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>export-dataweave-resources</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>ExportDataweaveResources</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <!-- Redefining MTF for jacoco and other plugins here -->
                    <groupId>com.mulesoft.munit</groupId>
                    <artifactId>munit-extensions-maven-plugin</artifactId>
                    <version>${munit-extensions-maven-plugin.version}</version>
                    <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-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>
                        <dependency>
                            <groupId>org.jacoco</groupId>
                            <artifactId>org.jacoco.agent</artifactId>
                            <version>${jacoco.version}</version>
                            <classifier>runtime</classifier>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.mule.weave</groupId>
                    <artifactId>data-weave-maven-plugin</artifactId>
                    <version>${data.weave.maven.plugin.version}</version>
                    <extensions>true</extensions>
                    <executions>
                        <execution>
                            <id>test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
            </plugin>
            <!-- W-11245480: MTS classloading issue -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
            </plugin>
            <!-- End of W-11245480 -->
            <plugin>
                <groupId>com.mulesoft.connectivity</groupId>
                <artifactId>rest-connector-commons-exported-packages-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.mulesoft.connectivity</groupId>
                <artifactId>citizen-platform-connectors-models-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>mule-releases</id>
            <name>Nexus Public Releases</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases/</url>
        </repository>
    </repositories>

    <!-- Enable HTTPS for Maven 3.8.0 -->
    <pluginRepositories>
        <pluginRepository>
            <id>mulesoft-plugin-releases</id>
            <name>MuleSoft Release Repository</name>
            <url>https://repository-master.mulesoft.org/releases/</url>
            <layout>default</layout>
        </pluginRepository>
        <pluginRepository>
            <id>mulesoft-plugin-snapshots</id>
            <name>MuleSoft Snapshots Repository</name>
            <url>https://repository-master.mulesoft.org/snapshots/</url>
            <layout>default</layout>
        </pluginRepository>
    </pluginRepositories>

</project>
