<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.mulesoft.runtime</groupId>
    <artifactId>mule-runtime-upgrade-tool</artifactId>
    <version>0.9.0-beta3</version>

    <name>Mule Runtime Upgrade Tool</name>
    <description>A tool for upgrading the mule runtime</description>
    <url>https://github.com/mulesoft/mule-runtime-upgrade-tool</url>

    <organization>
        <name>MuleSoft, Inc.</name>
        <url>http://www.mulesoft.com</url>
    </organization>

    <licenses>
        <license>
            <name>MSA</name>
            <url>https://www.mulesoft.com/</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>jmbarbosa80</id>
            <name>Jorge Barbosa</name>
            <email>jorge.barbosa@mulesoft.com</email>
            <roles>
                <role>Project Manager</role>
            </roles>
        </developer>
        <developer>
            <id>aiannucci</id>
            <name>Alejandro Iannucci</name>
        </developer>
        <developer>
            <id>anosenzo</id>
            <name>Alejandro Nosenzo</name>
        </developer>
        <developer>
            <id>lvzh90</id>
            <name>Linda Zapata</name>
        </developer>
        <developer>
            <id>garodriguezlp</id>
            <name>Gustavo Rodriguez</name>
        </developer>
        <developer>
            <id>fermartin17</id>
            <name>Fernando Martin</name>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/mulesoft/mule-runtime-upgrade-tool.git</connection>
        <developerConnection>scm:git:git@github.com:mulesoft/mule-runtime-upgrade-tool.git</developerConnection>
        <url>https://github.com/mulesoft/mule-runtime-upgrade-tool</url>
    </scm>

    <properties>
        <javaVersion>1.8</javaVersion>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

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

        <mulesoftLicenseVersion>1.0.3</mulesoftLicenseVersion>
        <license.maven.plugin.version>4.1</license.maven.plugin.version>
        <licensePath>LICENSE_HEADER_80.txt</licensePath>

        <licenseYear>2021</licenseYear>
        <skipVerifications>false</skipVerifications>

        <jacoco.version>0.8.7</jacoco.version>

        <allure-junit5.version>2.16.1</allure-junit5.version>
        <aspectj.version>1.9.7</aspectj.version>

        <maven.enforcer.plugin.version>3.0.0</maven.enforcer.plugin.version>
        <picocli-spring-boot-starter.version>4.6.2</picocli-spring-boot-starter.version>
        <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
        <commons-io.version>2.11.0</commons-io.version>
        <commons-compress.version>1.21</commons-compress.version>
        <commons-codec.version>1.15</commons-codec.version>

        <!-- Test dependencies versions -->
        <commons-lang3.version>3.12.0</commons-lang3.version>
        <zip4j.version>2.9.1</zip4j.version>
        <shrinkwrap-resolver.version>3.1.4</shrinkwrap-resolver.version>

        <!-- Using surefire/failsafe 3.0.0-M6-SNAPSHOT version to avoid SUREFIRE-1659 after adding log4j2 -->
        <!-- Error message "Corrupted STDOUT by directly writing to native stream in forked JVM 1..." -->
        <surefire.version>3.0.0-M5</surefire.version>
        <failsafe.version>3.0.0-M5</failsafe.version>
        <assembly.version>3.3.0</assembly.version>
        <resources.version>3.2.0</resources.version>
        <mule.runtime.process.controller.version>4.4.0</mule.runtime.process.controller.version>
    </properties>

    <dependencies>

        <!-- Start: Versions managed by Spring boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>${commons-codec.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>
        <!-- End: Versions managed by Spring boot -->

        <dependency>
            <groupId>info.picocli</groupId>
            <artifactId>picocli-spring-boot-starter</artifactId>
            <version>${picocli-spring-boot-starter.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-compress</artifactId>
            <version>${commons-compress.version}</version>
        </dependency>

        <!-- Start: Testing versions managed by Spring boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- End: Testing versions managed by Spring boot -->

        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-junit5</artifactId>
            <version>${allure-junit5.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.lingala.zip4j</groupId>
            <artifactId>zip4j</artifactId>
            <version>${zip4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-depchain</artifactId>
            <version>${shrinkwrap-resolver.version}</version>
            <scope>test</scope>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.mule.tooling</groupId>
            <artifactId>mule-runtime-process-controller</artifactId>
            <version>${mule.runtime.process.controller.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${license.maven.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>com.mulesoft.license</groupId>
                        <artifactId>license</artifactId>
                        <version>${mulesoftLicenseVersion}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <header>${licensePath}</header>
                    <properties>
                        <year>${licenseYear}</year>
                    </properties>
                    <excludes>
                        <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>
                        <exclude>**/build-number.txt</exclude>
                    </excludes>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <mapping>
                        <java>SLASHSTAR_STYLE</java>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </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>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>${formatterGoal}</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <configuration>
                    <skip>${skipTests}</skip>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                <artifactId>shrinkwrap-resolver-maven-plugin</artifactId>
                <version>${shrinkwrap-resolver.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>propagate-execution-context</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire.version}</version>
                <configuration>
                    <testFailureIgnore>false</testFailureIgnore>
                    <argLine>
                        @{argLine}
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                    <systemPropertyVariables>
                        <allure.results.directory>${project.build.directory}/allure-results</allure.results.directory>
                        <wrapper-tests-directory>${project.build.directory}/wrapper-tests</wrapper-tests-directory>
                    </systemPropertyVariables>
                    <!-- Added trimStackTrace to see the complete stacktrace when the error is in our JUnit 5 extensions code -->
                    <trimStackTrace>false</trimStackTrace>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${assembly.version}</version>
                <executions>
                    <execution>
                        <id>create-zip-package</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/wrapper.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${resources.version}</version>
                <executions>
                    <execution>
                        <id>setup-linux-unit-testing</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/wrapper-tests</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/bin</directory>
                                    <filtering>true</filtering>
                                    <includes>
                                        <include>upgrade-tool</include>
                                        <include>upgrade-tool.ps1</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>mule-ee-releases</id>
            <name>Mule Release Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-releases</url>
        </repository>
        <snapshotRepository>
            <id>mule-ee-snapshots</id>
            <name>Mule Snapshot Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-snapshots</url>
            <uniqueVersion>false</uniqueVersion>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>mule</id>
            <name>Mule Repository</name>
            <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
        </repository>
        <repository>
            <id>mulesoft-private</id>
            <name>Mulesoft internal repository</name>
            <url>https://repository.mulesoft.org/nexus/content/repositories/private/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>mule-plugin</id>
            <name>Mule Repository</name>
            <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
        </pluginRepository>
        <pluginRepository>
            <id>apache.snapshots</id>
            <url>https://repository.apache.org/snapshots/</url>
            <snapshots>
                <!-- Using 'never' it only downloads the surefire 3.0.0-M6-SNAPSHOT in case doesn't exist  -->
                <!-- And we avoid downloading them each day as we only need the fix for SUREFIRE-1659 which is already fixed -->
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <profiles>
        <profile>
            <id>release</id>
            <properties>
                <skipVerifications>false</skipVerifications>
                <skipNoSnapshotsEnforcerPluginRule>false</skipNoSnapshotsEnforcerPluginRule>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <additionalparam>${xDocLint}</additionalparam>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>${maven.enforcer.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>enforce-no-snapshots-in-deps</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireReleaseDeps>
                                            <message>No Snapshots Allowed in Deps!</message>
                                        </requireReleaseDeps>
                                        <requireReleaseVersion>
                                            <message>No Snapshots Allowed in Project Version!</message>
                                        </requireReleaseVersion>
                                        <requirePluginVersions>
                                            <message>Best Practice is to always define plugin versions!</message>
                                            <unCheckedPluginList>
                                                org.apache.maven.plugins:maven-clean-plugin,
                                                org.apache.maven.plugins:maven-install-plugin,
                                                org.apache.maven.plugins:maven-source-plugin,
                                                org.apache.maven.plugins:maven-site-plugin,
                                                org.apache.maven.plugins:maven-javadoc-plugin,
                                                org.apache.maven.plugins:maven-deploy-plugin,
                                                org.apache.maven.plugins:maven-resources-plugin,
                                                org.apache.maven.plugins:maven-jar-plugin,
                                                org.apache.maven.plugins:maven-surefire-plugin,
                                            </unCheckedPluginList>
                                        </requirePluginVersions>
                                    </rules>
                                    <skip>${skipNoSnapshotsEnforcerPluginRule}</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>it</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${failsafe.version}</version>
                        <configuration>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                            <systemPropertyVariables>
                                <allure.results.directory>${project.build.directory}/allure-results</allure.results.directory>
                                <FAILSAFE_TESTS_UPGRADE_TOOL_JAR_PATH>target/${project.artifactId}-${project.version}.jar</FAILSAFE_TESTS_UPGRADE_TOOL_JAR_PATH>
                            </systemPropertyVariables>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>skipVerifications</id>
            <activation>
                <property>
                    <name>skipVerifications</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <formatter.skip>true</formatter.skip>
                <license.skip>true</license.skip>
            </properties>
        </profile>
    </profiles>
</project>
