<?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/xsd/maven-4.0.0.xsd">

    <parent>
        <groupId>org.mule.extensions</groupId>
        <artifactId>mule-core-modules-parent</artifactId>
        <version>1.3.2</version>
        <relativePath />
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.mule.connectors</groupId>
    <artifactId>mule-sftp-connector</artifactId>
    <packaging>mule-extension</packaging>
    <version>2.7.1</version>

    <name>SFTP Connector - Mule 4</name>
    <description>A Mule extension that provides functionality to manage files in an SFTP server</description>

    <properties>
        <!-- Docker platform: set to linux/amd64 for Mac ARM or via CLI with key -Ddocker.platform, leave empty otherwise -->
        <docker.platform></docker.platform>
        <sonar.coverage.exclusions>
            **org/mule/extension/sftp/api/**
        </sonar.coverage.exclusions>
        <sonar.exclusions>
            **org/mule/extension/sftp/api/**
        </sonar.exclusions>
        <maven.helper.plugin.version>3.4.0</maven.helper.plugin.version>
        <exec.maven.plugin.version>3.6.3</exec.maven.plugin.version>
        <apache.maven.help.plugin.version>3.4.0</apache.maven.help.plugin.version>
        <maven.jdeps.plugin.version>3.1.2</maven.jdeps.plugin.version>
        <commonsIoVersion>2.21.0</commonsIoVersion>
        <commonsLangVersion>3.20.0</commonsLangVersion>
        <commonsCollections4Version>4.5.0</commonsCollections4Version>
        <connector.maven.plugin.version>3.0.2</connector.maven.plugin.version>

        <muleTestsComponentPlugin>${mule.version}</muleTestsComponentPlugin>
        <muleTestsRunnerVersion>4.1.5</muleTestsRunnerVersion>
        <muleSdkApiVersion>0.12.0</muleSdkApiVersion>
        <muleSdkCompatibilityApiVersion>0.5.0</muleSdkCompatibilityApiVersion>

        <!-- Remove when a new parent version with MTF is available -->
        <munit.input.directory>src/test/munit</munit.input.directory>
        <munit.output.directory>${basedir}/target/test-mule/munit</munit.output.directory>
        <munit.extensions.maven.plugin.version>1.7.0</munit.extensions.maven.plugin.version>
        <munit.version>3.7.0</munit.version>
        <mavenResources.version>3.3.1</mavenResources.version>
        <!--        Refer W-19865818 before changing sshdVersion-->
        <sshdVersion>2.17.1</sshdVersion>
        <formatterConfigPath>formatter.xml</formatterConfigPath>
        <settingsFile>${java.io.tmpdir}/effective-settings.xml</settingsFile>
        <mtf.tools.version>1.2.0</mtf.tools.version>
        <mtf.javaopts></mtf.javaopts>
        <jacoco.version>0.8.14</jacoco.version>
        <maven.impsort.plugin.version>1.6.2</maven.impsort.plugin.version>
        <maven.checkstyle.plugin.version>3.1.2</maven.checkstyle.plugin.version>
        <importGoal>check</importGoal>
        <slf4jApi.version>2.0.7</slf4jApi.version>
        <bcprovJDK15on.version>1.59</bcprovJDK15on.version>
        <muleJavaModule.version>1.2.16</muleJavaModule.version>
        <maven.invoker.plugin.version>3.6.0</maven.invoker.plugin.version>
        <muleConnectionTestModule.version>1.0.0</muleConnectionTestModule.version>
        <junit.version>4.13.1</junit.version>
        <maven.repo.local>${settings.localRepository}</maven.repo.local>
        <orgJson.version>20251224</orgJson.version>

        <mulesoftLicenseVersion>1.4.0</mulesoftLicenseVersion>
        <license.maven.plugin.version>4.2</license.maven.plugin.version>
        <licensePath>LICENSE_HEADER_CPAL.txt</licensePath>
        <licenseYear>2023</licenseYear>
    </properties>

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

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commonsIoVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commonsLangVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>${commonsCollections4Version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.sshd</groupId>
            <artifactId>sshd-core</artifactId>
            <version>${sshdVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.sshd</groupId>
            <artifactId>sshd-sftp</artifactId>
            <version>${sshdVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.sshd</groupId>
            <artifactId>sshd-common</artifactId>
            <version>${sshdVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4jApi.version}</version>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>${orgJson.version}</version>
        </dependency>

        <!--Test Dependencies-->
        <dependency>
            <groupId>org.apache.sshd</groupId>
            <artifactId>sshd-scp</artifactId>
            <version>${sshdVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.tests</groupId>
            <artifactId>mule-tests-infrastructure</artifactId>
            <version>${mule.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.sshd</groupId>
                    <artifactId>sshd-core</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>bcprov-jdk15on</artifactId>
                    <groupId>org.bouncycastle</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.mule.tests.plugin</groupId>
            <artifactId>mule-tests-component-plugin</artifactId>
            <version>${muleTestsComponentPlugin}</version>
            <classifier>mule-plugin</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-core</artifactId>
            <version>${mule.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.tests</groupId>
            <artifactId>mule-tests-functional</artifactId>
            <version>${mule.version}</version>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>net.i2p.crypto</groupId>
            <artifactId>eddsa</artifactId>
            <version>0.3.0</version>
            <type>jar</type>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${maven.helper.plugin.version}</version>
                <executions>
                    <execution>
                        <id>reserve-network-port</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>reserve-network-port</goal>
                        </goals>
                        <configuration>
                            <portNames>
                                <portName>sftp.listener.port</portName>
                                <portName>squid.port.auth</portName>
                                <portName>sftp.proxy.auth</portName>
                                <portName>sftp.atmoz.port</portName>
                                <portName>dante.proxy.port</portName>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>docker-compose-up</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>docker</executable>
                            <arguments>
                                <argument>compose</argument>
                                <argument>-f</argument>
                                <argument>${project.basedir}/src/test/resources/docker/docker-compose.yml</argument>
                                <argument>-p</argument>
                                <argument>${squid.port.auth}_${sftp.proxy.auth}</argument>
                                <argument>up</argument>
                                <argument>-d</argument>
                                <argument>--build</argument>
                            </arguments>
                            <environmentVariables>
                                <sftpListenerPort>${sftp.listener.port}</sftpListenerPort>
                                <squidPortAuth>${squid.port.auth}</squidPortAuth>
                                <sftpProxyAuth>${sftp.proxy.auth}</sftpProxyAuth>
                                <sftpAtmozServer>${sftp.atmoz.port}</sftpAtmozServer>
                                <sftpProxyDante>${dante.proxy.port}</sftpProxyDante>
                                <DOCKER_PLATFORM>${docker.platform}</DOCKER_PLATFORM>
                            </environmentVariables>
                            <skip>${docker.skip}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>docker-compose-down</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>docker</executable>
                            <arguments>
                                <argument>compose</argument>
                                <argument>-f</argument>
                                <argument>${project.basedir}/src/test/resources/docker/docker-compose.yml</argument>
                                <argument>-p</argument>
                                <argument>${squid.port.auth}_${sftp.proxy.auth}</argument>
                                <argument>down</argument>
                            </arguments>
                            <skip>${docker.skip}</skip>
                        </configuration>
                    </execution>
                </executions>
            </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>
                    <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>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${mavenResources.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>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>
                    <productConfiguration>
                        <discoverProducts>
                            <discoverProduct>
                                <id>MULE_EE</id>
                                <minVersion>${minVersion}</minVersion>
                            </discoverProduct>
                        </discoverProducts>
                    </productConfiguration>
                    <argLines>
                        <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>
                    <environmentVariables>
                        <!-- Toggles the JDK17 style flag -->
                        <!-- ugly hack -->
                        <_JAVA_OPTIONS>-XX:+PrintCommandLineFlags ${mtf.javaopts}</_JAVA_OPTIONS>
                    </environmentVariables>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>munit-runner</artifactId>
                        <version>${munit.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>${junit.version}</version>
                    </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.apache.sshd</groupId>
                        <artifactId>sshd-core</artifactId>
                        <version>${sshdVersion}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.sshd</groupId>
                        <artifactId>sshd-sftp</artifactId>
                        <version>${sshdVersion}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.sshd</groupId>
                        <artifactId>sshd-common</artifactId>
                        <version>${sshdVersion}</version>
                    </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>
                        <id>prepare-agent</id>
                        <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>${session.executionRootDirectory}/target</directory>
                                    <includes>
                                        <include>*.exec</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${session.executionRootDirectory}/target/jacoco.exec</dataFile>
                            <outputDirectory>${session.executionRootDirectory}/target/jacoco</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-help-plugin</artifactId>
                <version>${apache.maven.help.plugin.version}</version>
                <executions>
                    <execution>
                        <phase>process-test-resources</phase>
                        <id>copy-settings</id>
                        <goals>
                            <goal>effective-settings</goal>
                        </goals>
                        <configuration>
                            <output>${settingsFile}</output>
                            <showPasswords>true</showPasswords>
                        </configuration>
                    </execution>
                </executions>
            </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>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>${maven.invoker.plugin.version}</version>
                <configuration>
                    <debug>true</debug>
                    <streamLogs>true</streamLogs>
                    <noLog>true</noLog>
                    <cloneProjectsTo>${project.build.directory}/test/it</cloneProjectsTo>
                    <properties>
                        <maven.settings.local>${settingsFile}</maven.settings.local>
                        <sftp.listener.port>${sftp.listener.port}</sftp.listener.port>
                    </properties>
                    <skipInvocation>${skipITs}</skipInvocation>
                </configuration>
                <executions>
                    <execution>
                        <id>tita-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <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>

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

    <pluginRepositories>
        <pluginRepository>
            <id>mule-plugin</id>
            <name>Mule Repository</name>
            <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
        </pluginRepository>
    </pluginRepositories>
</project>
