<?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>

    <groupId>com.mulesoft.modules</groupId>
    <artifactId>mule-wss-module</artifactId>
    <version>1.1.3</version>
    <packaging>mule-extension</packaging>

    <name>Web Service Security Module</name>
    <description>A Mule extension that provides functionality for applying security to Web Services</description>

    <parent>
        <groupId>org.mule.extensions</groupId>
        <artifactId>mule-ee-core-modules-parent</artifactId>
        <version>1.1.10</version>
    </parent>

    <properties>
        <licenseYear>2021</licenseYear>
        <wss4j.version>2.4.1</wss4j.version>
        <spring.version>5.8.3</spring.version>
        <jaxws-rt.version>2.3.6</jaxws-rt.version>

        <formatterConfigPath>formatter.xml</formatterConfigPath>

        <!-- 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.1.3</munit.extensions.maven.plugin.version>
        <munit.version>2.3.16</munit.version>

        <docker.maven.plugin.version>0.43.0</docker.maven.plugin.version>
        <docker.skip>${skipTests}</docker.skip>
        <powermock.version>2.0.9</powermock.version>
        <maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
        <maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
        <jacoco.version>0.8.7</jacoco.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-ldap</artifactId>
            <version>${spring.version}</version>

            <exclusions>
                <exclusion>
                    <!-- This artifact doesn't end up being used and has known issues until 6.0.0 (6.0.0 has Java 17 as baseline) -->
                    <groupId>org.springframework.security</groupId>
                    <artifactId>spring-security-crypto</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.wss4j</groupId>
            <artifactId>wss4j-ws-security-dom</artifactId>
            <version>${wss4j.version}</version>

            <exclusions>
                <exclusion>
                    <!-- This artifact doesn't end up being used and includes a jar-packaged vm agent -->
                    <groupId>org.ehcache</groupId>
                    <artifactId>ehcache</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Java 11 support -->
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>${jaxws-rt.version}</version>
        </dependency>

        <!--testing-->
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito2</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <!-- from org.apache.wss4j:wss4j-ws-security-dom -->
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-jdk15on</artifactId>
                <version>1.70</version>
            </dependency>
	    <!-- from org.mule.extensions:mule-ee-core-modules-parent -->
	    <!--     from org.mule.services:mule-service-scheduler -->
	    <!-- The dep is unused. This ghost version bump is made so analysis tools don't get angry at us -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>32.0.0-jre</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <distributionManagement>
        <repository>
            <id>mule-ee-releases</id>
            <name>Mule Release Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases-ee</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>

    <build>
        <pluginManagement>
            <plugins>
                <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>
                                -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>
                        <runtimeConfiguration>
                            <discoverRuntimes>
                                <product>EE</product>
                                <includeSnapshots>true</includeSnapshots>
                            </discoverRuntimes>
                        </runtimeConfiguration>
                        <environmentVariables>
                            <LDAP_PORT>${ldap.port}</LDAP_PORT>
                        </environmentVariables>
                    </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>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>${docker.maven.plugin.version}</version>
                <configuration>
                    <images>
                        <image>
                            <name>rroemhild/test-openldap:latest</name>
                            <build>
                                <dockerFileDir>${project.basedir}</dockerFileDir>
                            </build>
                            <run>
                                <ports>
                                    <port>ldap.port:10389</port>
                                </ports>
                                <log>
                                    <enabled>false</enabled>
                                </log>
                                <!--Workaround for avoiding name collisions with zombie containers left from failed executions-->
                                <!--or parallel executions on same agent-->
                                <containerNamePattern>%n-%i-%t</containerNamePattern>
                            </run>
                        </image>
                    </images>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <id>start</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>build</goal>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <showLogs>false</showLogs>
                            <logStdout>false</logStdout>
                        </configuration>
                    </execution>
                    <!--https://github.com/fabric8io/docker-maven-plugin/issues/915, if tests fail, run docker stop <CONTAINER_ID>-->
                    <execution>
                        <id>stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <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>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>com.mulesoft.munit</groupId>
                <artifactId>munit-extensions-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jdk11</id>
            <activation>
                <jdk>11</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>munit-extensions-maven-plugin</artifactId>
                        <configuration>
                            <runtimeConfiguration>
                                <discoverRuntimes>
                                    <minMuleVersion>4.2.0</minMuleVersion>
                                </discoverRuntimes>
                            </runtimeConfiguration>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
