<?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.1.8</version>
        <relativePath></relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.mule.connectors</groupId>
    <artifactId>mule-db-connector</artifactId>
    <packaging>mule-extension</packaging>
    <version>1.9.2</version>

    <name>Database Connector</name>
    <description>A Mule extension that provides functionality for connecting to Databases through the JDBC standard</description>

    <properties>
        <c3p0Version>0.9.5.5</c3p0Version>
        <commonsCollectionsVersion>3.2.2</commonsCollectionsVersion>
        <commonsDbUtilsVersion>1.7</commonsDbUtilsVersion>
        <commonsLangVersion>3.11</commonsLangVersion>
        <commonsIoVersion>2.8.0</commonsIoVersion>
        <mockito-core.version>3.6.0</mockito-core.version>
        <xmlunit.version>1.6</xmlunit.version>
        <caffeineVersion>2.8.6</caffeineVersion>
        <javax.transaction.version>1.3</javax.transaction.version>
        <xaPoolVersion>1.5.0</xaPoolVersion>
        <cglibVersion>3.3.0</cglibVersion>
        <derbyVersion>10.11.1.1</derbyVersion>
        <mySqlVersion>8.0.22</mySqlVersion>
        <mssqlVersion>7.0.0.jre8</mssqlVersion>
        <oracle.driver.version>19.8.0.0</oracle.driver.version>
        
        <docker.maven.plugin.version>0.34.1</docker.maven.plugin.version>
        <maven-replacer-plugin.version>1.5.3</maven-replacer-plugin.version>

        <formatterConfigPath>formatter.xml</formatterConfigPath>

        <munit.extensions.maven.plugin.version>1.0.0</munit.extensions.maven.plugin.version>
        <munit.version>2.2.4</munit.version>
        <mtf-tools.version>1.0.0</mtf-tools.version>
        <skipTests>false</skipTests>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>${c3p0Version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commonsLangVersion}</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commonsIoVersion}</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>${commonsCollectionsVersion}</version>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>javax.transaction-api</artifactId>
            <version>${javax.transaction.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>caffeine</artifactId>
            <version>${caffeineVersion}</version>
        </dependency>

        <dependency>
            <groupId>com.experlog</groupId>
            <artifactId>xapool</artifactId>
            <version>${xaPoolVersion}</version>
        </dependency>

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

        <dependency>
            <groupId>commons-dbutils</groupId>
            <artifactId>commons-dbutils</artifactId>
            <version>${commonsDbUtilsVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>xmlunit</groupId>
            <artifactId>xmlunit</artifactId>
            <version>${xmlunit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>${cglibVersion}</version>
        </dependency>

        <!-- DB Drivers -->
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>${derbyVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mySqlVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>${mssqlVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>${oracle.driver.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <!-- Needed artifact for testing purposes on mule-ee/tests/xa-tx-->
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>${skipTests}</skipTests>
                    <systemPropertyVariables>
                        <oracle.db.port>${oracle.db.port}</oracle.db.port>
                        <mysql.db.port>${mysql.db.port}</mysql.db.port>
                        <mssql.db.port>${mssql.db.port}</mssql.db.port>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.mulesoft.munit</groupId>
                <artifactId>munit-extensions-maven-plugin</artifactId>
                <version>${munit.extensions.maven.plugin.version}</version>
                <configuration>
                    <munitFailIfNoTests>false</munitFailIfNoTests>
                    <runtimeProduct>MULE_EE</runtimeProduct>
                    <systemPropertyVariables>
                        <oracle.db.port>${oracle.db.port}</oracle.db.port>
                    </systemPropertyVariables>
                    <munitTest>.*TestCase.xml</munitTest>
                    <runtimeConfiguration>
                        <discoverRuntimes>
                            <product>EE</product>
                        </discoverRuntimes>
                    </runtimeConfiguration>
                    <sharedLibraries>
                        <sharedLibrary>
                            <groupId>com.oracle.database.jdbc</groupId>
                            <artifactId>ojdbc8</artifactId>
                        </sharedLibrary>
                    </sharedLibraries>
                </configuration>
                <executions>
                    <execution>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </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>
            <activation>
                <property>
                    <name>oracle</name>
                    <value>true</value>
                </property>
            </activation>
            <id>oracle</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker.maven.plugin.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>store/oracle/database-enterprise:12.2.0.1-slim</name>
                                    <run>
                                        <ports>
                                            <port>oracle.db.port:1521</port>
                                        </ports>
                                        <ulimits>
                                            <ulimit>
                                                <name>nofile</name>
                                                <hard>10240</hard>
                                                <soft>10240</soft>
                                            </ulimit>
                                        </ulimits>
                                        <log>
                                            <enabled>true</enabled>
                                        </log>
                                        <wait>
                                            <log>Done ! The database is ready for use .</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.30</version>
                            </dependency>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>jcl-over-slf4j</artifactId>
                                <version>1.7.30</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>test-compile</phase>
                                <goals>
                                    <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>
            <activation>
                <property>
                    <name>mysql</name>
                    <value>true</value>
                </property>
            </activation>
            <id>mysql</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker.maven.plugin.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>mysql:latest</name>
                                    <alias>mysql-container</alias>
                                    <run>
                                        <containerNamePattern>%a</containerNamePattern>
                                        <env>
                                            <MYSQL_ROOT_PASSWORD>password</MYSQL_ROOT_PASSWORD>
                                            <MYSQL_DATABASE>xe</MYSQL_DATABASE>
                                        </env>
                                        <ports>
                                            <port>mysql.db.port:3306</port>
                                        </ports>
                                        <ulimits>
                                            <ulimit>
                                                <name>nofile</name>
                                                <hard>10240</hard>
                                                <soft>10240</soft>
                                            </ulimit>
                                        </ulimits>
                                        <log>
                                            <enabled>true</enabled>
                                        </log>
                                        <wait>
                                            <log>mysqld: ready for connections.</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.30</version>
                            </dependency>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>jcl-over-slf4j</artifactId>
                                <version>1.7.30</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>test-compile</phase>
                                <goals>
                                    <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>
            <activation>
                <property>
                    <name>mysql-old-version</name>
                    <value>true</value>
                </property>
            </activation>
            <id>mysql-old-version</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker.maven.plugin.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>mysql:latest</name>
                                    <alias>mysql-old-version-container</alias>
                                    <run>
                                        <containerNamePattern>%a</containerNamePattern>
                                        <env>
                                            <MYSQL_ROOT_PASSWORD>password</MYSQL_ROOT_PASSWORD>
                                            <MYSQL_DATABASE>xe</MYSQL_DATABASE>
                                        </env>
                                        <ports>
                                            <port>mysql.db.port:3306</port>
                                        </ports>
                                        <ulimits>
                                            <ulimit>
                                                <name>nofile</name>
                                                <hard>10240</hard>
                                                <soft>10240</soft>
                                            </ulimit>
                                        </ulimits>
                                        <log>
                                            <enabled>true</enabled>
                                        </log>
                                        <wait>
                                            <log>mysqld: ready for connections.</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.30</version>
                            </dependency>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>jcl-over-slf4j</artifactId>
                                <version>1.7.30</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>test-compile</phase>
                                <goals>
                                    <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>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>5.1.49</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <activation>
                <property>
                    <name>mssql</name>
                    <value>true</value>
                </property>
            </activation>
            <id>mssql</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker.maven.plugin.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>microsoft/mssql-server-linux</name>
                                    <run>
                                        <env>
                                            <SA_PASSWORD>yourStrong(!)Password</SA_PASSWORD>
                                            <ACCEPT_EULA>Y</ACCEPT_EULA>
                                        </env>
                                        <ports>
                                            <port>mssql.db.port:1433</port>
                                        </ports>
                                        <ulimits>
                                            <ulimit>
                                                <name>nofile</name>
                                                <hard>10240</hard>
                                                <soft>10240</soft>
                                            </ulimit>
                                        </ulimits>
                                        <log>
                                            <enabled>true</enabled>
                                        </log>
                                        <wait>
                                            <log>Service Broker manager has started.</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.30</version>
                            </dependency>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>jcl-over-slf4j</artifactId>
                                <version>1.7.30</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>test-compile</phase>
                                <goals>
                                    <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>

    <distributionManagement>
        <downloadUrl>http://www.mulesoft.org/display/MULE/Download</downloadUrl>
        <repository>
            <id>mule-releases</id>
            <name>Mule Release Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases</url>
        </repository>
        <snapshotRepository>
            <id>mule-snapshots</id>
            <name>Mule Snapshot Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/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>
    </repositories>

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

</project>
