<?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.2.0</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.2</version>
    </parent>

    <properties>
        <licenseYear>2018</licenseYear>

        <muleJmsClientVersion>1.1.4</muleJmsClientVersion>
        <ibmMqClientVersion>9.1.1.0</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.0.0-BETA</munit.extensions.maven.plugin.version>
        <munit.version>2.2.0-BETA</munit.version>
        <mavenResourcesVersion>3.0.2</mavenResourcesVersion>
        <mtf-tools.version>1.0.0-BETA</mtf-tools.version>
        <docker.maven.plugin.version>0.25.2</docker.maven.plugin.version>
        <maven.helper.plugin.version>3.0.0</maven.helper.plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.mule.connectors</groupId>
            <artifactId>mule-jms-client</artifactId>
            <version>${muleJmsClientVersion}</version>
        </dependency>
        <dependency>
            <groupId>com.ibm.mq</groupId>
            <artifactId>com.ibm.mq.allclient</artifactId>
            <version>${ibmMqClientVersion}</version>
            <scope>provided</scope>
        </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>
    </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>ibmmq.listener.port</portName>
                                <portName>ibmmq.web_console.port</portName>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <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>
                    <sharedLibraries>
                        <sharedLibrary>
                            <groupId>com.ibm.mq</groupId>
                            <artifactId>com.ibm.mq.allclient</artifactId>
                        </sharedLibrary>
                    </sharedLibraries>
                    <runtimeConfiguration>
                      <discoverRuntimes>
                           <product>EE</product>
                           <includeSnapshots>true</includeSnapshots>
                           <minMuleVersion>4.1.1</minMuleVersion>
                        </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>com.mulesoft.munit</groupId>
                        <artifactId>mtf-tools</artifactId>
                        <version>${mtf-tools.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>docker</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker.maven.plugin.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>ibmcom/mq:latest</name>
                                    <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>
                                        <ulimits>
                                            <ulimit>
                                                <name>nofile</name>
                                                <hard>10240</hard>
                                                <soft>10240</soft>
                                            </ulimit>
                                        </ulimits>
                                        <log>
                                            <enabled>true</enabled>
                                        </log>
                                        <wait>
                                        <log>Started queue manager</log>
                                        <time>500000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                            <verbose>true</verbose>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>slf4j-api</artifactId>
                                <version>1.7.24</version>
                            </dependency>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>jcl-over-slf4j</artifactId>
                                <version>1.7.24</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>
    </profiles>

</project>
