<?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.connectors</groupId>
    <artifactId>mule-ibm-mq-connector</artifactId>
    <version>1.7.4</version>
    <packaging>mule-extension</packaging>
    <name>IBM MQ Connector</name>

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

    <properties>
        <licenseYear>2021</licenseYear>
        <muleSdkApiVersion>0.7.0</muleSdkApiVersion>
        <muleJmsClientVersion>1.13.22</muleJmsClientVersion>
        <muleJmsTestConnectorVersion>1.9.7</muleJmsTestConnectorVersion>
        <!-- IBM MQ 9.3.5.0 makes the FIPS pipeline FAIL with connectivity exception-->
        <ibmMqClientVersion>9.3.4.1</ibmMqClientVersion>
        <httpServiceVersion>1.1.1</httpServiceVersion>
        <schedulerServiceVersion>1.1.0</schedulerServiceVersion>
        <!--MTF Dependencies-->
        <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.4.0</munit.extensions.maven.plugin.version>
        <munit.version>3.3.2</munit.version>
        <mtf.tools.version>1.2.0</mtf.tools.version>
        <munit.includeMuleSnapshots>false</munit.includeMuleSnapshots>
        <httpConnectorVersion>1.10.0</httpConnectorVersion>
        <mavenResourcesVersion>3.3.1</mavenResourcesVersion>
        <dockerClientVersion>8.16.0</dockerClientVersion>
        <docker.maven.plugin.version>0.45.0</docker.maven.plugin.version>
        <maven.helper.plugin.version>3.5.0</maven.helper.plugin.version>
        <ibmmq.admin.pass>passw0rd</ibmmq.admin.pass>
        <commonsCodecVersion>1.16.1</commonsCodecVersion>
        <jacoco.version>0.8.11</jacoco.version>
        <awaitility.version>4.2.1</awaitility.version>
        <java.module.version>1.2.13</java.module.version>
        <groovy.version>3.0.22</groovy.version>
        <scripting.version>2.1.0</scripting.version>
        <slf4j-api.version>2.0.13</slf4j-api.version>
        <jcl-over-slf4j.version>2.0.13</jcl-over-slf4j.version>
        <!-- Remove once jms-client 1.13.20+ is available -->
        <commonsLangVersion>3.17.0</commonsLangVersion>
        <commonsIoVersion>2.17.0</commonsIoVersion>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.mule.connectors</groupId>
            <artifactId>mule-jms-client</artifactId>
            <version>${muleJmsClientVersion}</version>
            <!-- Remove once jms-client 1.13.20+ is available -->
            <exclusions>
                <exclusion>
                    <groupId>commons-io</groupId>
                    <artifactId>commons-io</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Remove once jms-client 1.13.20+ is available -->
        <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>com.ibm.mq</groupId>
            <artifactId>com.ibm.mq.allclient</artifactId>
            <version>${ibmMqClientVersion}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcprov-jdk15to18</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcpkix-jdk15to18</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcutil-jdk15to18</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mule.sdk</groupId>
            <artifactId>mule-sdk-api</artifactId>
            <version>${muleSdkApiVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.mule.services</groupId>
            <artifactId>mule-service-http</artifactId>
            <version>${httpServiceVersion}</version>
            <classifier>mule-service</classifier>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.services</groupId>
            <artifactId>mule-service-scheduler</artifactId>
            <version>${schedulerServiceVersion}</version>
            <classifier>mule-service</classifier>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>${commonsCodecVersion}</version>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.spotify</groupId>
            <artifactId>docker-client</artifactId>
            <version>${dockerClientVersion}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcpkix-jdk15on</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>${awaitility.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jdeps-plugin</artifactId>
                <version>3.1.2</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>
            <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>ibmmq.listener.port</portName>
                                <portName>ibmmq.web_console.port</portName>
                                <portName>activemq.listener.port</portName>
                                <portName>activemq.web_console.port</portName>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${mavenResourcesVersion}</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>
                <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>
                    <systemPropertyVariables>
                        <avoid.dispose.mq.threads>true</avoid.dispose.mq.threads>
                    </systemPropertyVariables>
                    <sharedLibraries>
                        <sharedLibrary>
                            <groupId>com.ibm.mq</groupId>
                            <artifactId>com.ibm.mq.allclient</artifactId>
                        </sharedLibrary>
                        <sharedLibrary>
                            <groupId>org.apache.activemq</groupId>
                            <artifactId>activemq-all</artifactId>
                        </sharedLibrary>
                        <sharedLibrary>
                            <groupId>org.mule.connectors</groupId>
                            <artifactId>mule-jms-client</artifactId>
                        </sharedLibrary>
                        <sharedLibrary>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy</artifactId>
                        </sharedLibrary>
                        <sharedLibrary>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy-jsr223</artifactId>
                        </sharedLibrary>
                    </sharedLibraries>


                    <runtimeConfiguration>
                        <discoverRuntimes>
                            <minMuleVersion>${minVersion}</minMuleVersion>
                            <includeSnapshots>false</includeSnapshots>
                            <product>EE</product>
                        </discoverRuntimes>
                    </runtimeConfiguration>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                    </execution>
                </executions>
                <dependencies>
                    <!-- MUnit 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>org.mule.connectors</groupId>
                        <artifactId>mule-http-connector</artifactId>
                        <version>${httpConnectorVersion}</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.mule.connectors</groupId>
                        <artifactId>mule-jms-connector</artifactId>
                        <version>${muleJmsTestConnectorVersion}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>org.mule.module</groupId>
                        <artifactId>mule-java-module</artifactId>
                        <version>${java.module.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy</artifactId>
                        <version>${groovy.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-jsr223</artifactId>
                        <version>${groovy.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.mule.modules</groupId>
                        <artifactId>mule-scripting-module</artifactId>
                        <version>${scripting.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.activemq</groupId>
                        <artifactId>activemq-all</artifactId>
                        <version>5.15.4</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>docker</id>
            <activation>
                <os>
                    <family>!windows</family>
                </os>
            </activation>
            <properties>
                <munit.includeMuleSnapshots>true</munit.includeMuleSnapshots>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker.maven.plugin.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <run>
                                        <env>
                                            <LICENSE>accept</LICENSE>
                                            <MQ_QMGR_NAME>QM1</MQ_QMGR_NAME>
                                        </env>
                                        <ports>
                                            <port>${ibmmq.listener.port}:1414</port>
                                            <port>${ibmmq.web_console.port}:9443</port>
                                        </ports>
                                        <log>
                                            <enabled>true</enabled>
                                        </log>
                                    </run>
                                </image>
                            </images>
                            <verbose>true</verbose>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>slf4j-api</artifactId>
                                <version>${slf4j-api.version}</version>
                            </dependency>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>jcl-over-slf4j</artifactId>
                                <version>${jcl-over-slf4j.version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>build</goal>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <showLogs>true</showLogs>
                                    <logStdout>true</logStdout>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>docker-windows</id>
            <activation>
                <os>
                    <family>windows</family>
                    <name>windows server 2016</name>
                    <version>10.0</version>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <ibmmq.admin.pass>P@ssW0rD</ibmmq.admin.pass>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker.maven.plugin.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>artifacts.msap.io/mulesoft-onprem/windows-ibm-mq</name>
                                    <run>
                                        <wait>
                                            <!--Ideally, It'd be much better to wait for some sort of indication in the container's log for-->
                                            <!--validating a successful start. Nevertheless, it won't be possible in Windows due to-->
                                            <!--https://github.com/fabric8io/docker-maven-plugin/issues/1232 So, we hope this arbitrarily wait-->
                                            <!--time to be enough-->
                                            <time>10000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>docker-unix</id>
            <activation>
                <os>
                    <family>!windows</family>
                </os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker.maven.plugin.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>ibmcom/mq:9.2.4.0-r1</name>
                                    <alias>ibmmq-${ibmmq.listener.port}</alias>
                                    <run>
                                        <containerNamePattern>%a</containerNamePattern>
                                        <ulimits>
                                            <ulimit>
                                                <name>nofile</name>
                                                <hard>10240</hard>
                                                <soft>10240</soft>
                                            </ulimit>
                                        </ulimits>
                                        <wait>
                                            <log>Started queue manager</log>
                                            <time>500000</time>
                                        </wait>
                                    </run>
                                </image>
                                <image>
                                    <name>rmohr/activemq:5.15.9</name>
                                    <alias>activemq-${activemq.listener.port}</alias>
                                    <run>
                                        <containerNamePattern>%a</containerNamePattern>
                                        <ports>
                                            <port>${activemq.listener.port}:61616</port>
                                            <port>${activemq.web_console.port}:8161</port>
                                        </ports>
                                        <ulimits>
                                            <ulimit>
                                                <name>nofile</name>
                                                <hard>10240</hard>
                                                <soft>10240</soft>
                                            </ulimit>
                                        </ulimits>
                                        <log>
                                            <enabled>true</enabled>
                                        </log>
                                        <wait>
                                            <log>ActiveMQ Jolokia REST API available</log>
                                            <time>500000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
