<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  ~
  ~ WSO2 Inc. licenses this file to you under the Apache License,
  ~ Version 2.0 (the "License"); you may not use this file except
  ~ in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied. See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->

<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">
    <parent>
        <groupId>org.wso2.extension.siddhi.store.rdbms</groupId>
        <artifactId>siddhi-store-rdbms-parent</artifactId>
        <version>4.0.33</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <packaging>bundle</packaging>

    <artifactId>siddhi-store-rdbms</artifactId>
    <name>Siddhi Store RDBMS - Implementation</name>

    <dependencies>
        <dependency>
            <groupId>org.wso2.siddhi</groupId>
            <artifactId>siddhi-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.siddhi</groupId>
            <artifactId>siddhi-query-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.log4j.wso2</groupId>
            <artifactId>log4j</artifactId>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.datasources</groupId>
            <artifactId>org.wso2.carbon.datasource.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-catalina</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>sqljdbc4</artifactId>
            <scope>test</scope>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>com.ibm.db2</groupId>-->
            <!--<artifactId>db2jcc</artifactId>-->
            <!--<scope>test</scope>-->
            <!--<version>4.19.26</version>-->
        <!--</dependency>-->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.artifactId}</Bundle-Name>
                        <Private-Package>
                            !com.zaxxer.hikari.*,
                        </Private-Package>
                        <Export-Package>
                            !com.zaxxer.hikari.*,
                            org.wso2.extension.siddhi.store.rdbms.*,
                            org.wso2.extension.siddhi.execution.rdbms.*
                        </Export-Package>
                        <Import-Package>
                            *;resolution:=optional
                        </Import-Package>
                        <DynamicImport-Package>*</DynamicImport-Package>
                        <Include-Resource>
                            META-INF=target/classes/META-INF,
                            {maven-resources}
                        </Include-Resource>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <property>
                            <name>carbon.home</name>
                            <value>${basedir}/src/test/resources/</value>
                        </property>
                    </systemProperties>
                    <skip>${skip.surefire.test}</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <mavan.findbugsplugin.exclude.file>../findbugs-exclude.xml</mavan.findbugsplugin.exclude.file>
    </properties>

    <profiles>
        <profile>
            <id>documentation-deploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.wso2.siddhi</groupId>
                        <artifactId>siddhi-doc-gen</artifactId>
                        <version>${siddhi.version}</version>
                        <executions>
                            <execution>
                                <phase>compile</phase>
                                <goals>
                                    <goal>deploy-mkdocs-github-pages</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-all</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.5.0</version>
                        <executions>
                            <execution>
                                <id>run-h2</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>mvn</executable>
                                    <arguments>
                                        <argument>verify</argument>
                                        <argument>-P local-h2</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>run-mysql</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>mvn</executable>
                                    <arguments>
                                        <argument>verify</argument>
                                        <argument>-P local-mysql</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>run-postgres</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>mvn</executable>
                                    <arguments>
                                        <argument>verify</argument>
                                        <argument>-P local-postgres</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>run-oracle</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>mvn</executable>
                                    <arguments>
                                        <argument>verify</argument>
                                        <argument>-P local-oracle</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>run-mssql</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>mvn</executable>
                                    <arguments>
                                        <argument>verify</argument>
                                        <argument>-P local-mssql</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <!--<execution>-->
                                <!--<id>run-db2</id>-->
                                <!--<phase>integration-test</phase>-->
                                <!--<goals>-->
                                    <!--<goal>exec</goal>-->
                                <!--</goals>-->
                                <!--<configuration>-->
                                    <!--<executable>mvn</executable>-->
                                    <!--<arguments>-->
                                        <!--<argument>verify</argument>-->
                                        <!--<argument>-P local-db2</argument>-->
                                    <!--</arguments>-->
                                <!--</configuration>-->
                            <!--</execution>-->
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-h2</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jacoco-initialize</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${basedir}/target/coverage-reports/jacoco.exec</destFile>
                                    <propertyName>jcoverage.command</propertyName>
                                </configuration>
                            </execution>
                            <execution>
                                <id>jacoco-site</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <configuration>
                                    <dataFile>${basedir}/target/coverage-reports/jacoco.exec</dataFile>
                                    <outputDirectory>${basedir}/target/coverage-reports/</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.19.1</version>
                        <executions>
                            <execution>
                                <id>integration-test-for-h2</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-h2</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <argLine>${jcoverage.command}</argLine>
                            <environmentVariables>
                                <DATABASE_TYPE>H2</DATABASE_TYPE>
                            </environmentVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-mysql</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-mysql</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-mysql</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <images>
                                <image>
                                    <alias>das-mysql</alias>
                                    <name>mysql:5.7</name>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <env>
                                            <MYSQL_DATABASE>dasdb</MYSQL_DATABASE>
                                            <MYSQL_ROOT_PASSWORD>root</MYSQL_ROOT_PASSWORD>
                                        </env>
                                        <ports>
                                            <port>${das-mysql.port}:3306</port>
                                        </ports>
                                        <wait>
                                            <tcp>
                                                <ports>
                                                    <port>3306</port>
                                                </ports>
                                            </tcp>
                                            <time>60000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.19.1</version>
                        <executions>
                            <execution>
                                <id>integration-test-for-mysql</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-mysql</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <environmentVariables>
                                <DATABASE_TYPE>MySQL</DATABASE_TYPE>
                                <DATABASE_USER>root</DATABASE_USER>
                                <DATABASE_PASSWORD>root</DATABASE_PASSWORD>
                                <PORT>${das-mysql.port}</PORT>
                                <DOCKER_HOST_IP>${docker.container.das-mysql.ip}</DOCKER_HOST_IP>
                            </environmentVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-postgres</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-postgres</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-postgres</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <images>
                                <image>
                                    <alias>das-postgres</alias>
                                    <name>postgres:9.6</name>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <env>
                                            <POSTGRES_PASSWORD>root</POSTGRES_PASSWORD>
                                            <POSTGRES_USER>root</POSTGRES_USER>
                                            <POSTGRES_DB>dasdb</POSTGRES_DB>
                                        </env>
                                        <ports>
                                            <port>${das-postgres.port}:5432</port>
                                        </ports>
                                        <wait>
                                            <tcp>
                                                <ports>
                                                    <port>5432</port>
                                                </ports>
                                            </tcp>
                                            <time>60000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.19.1</version>
                        <executions>
                            <execution>
                                <id>integration-test-for-postgres</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-postgres</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <environmentVariables>
                                <DATABASE_TYPE>POSTGRES</DATABASE_TYPE>
                                <DATABASE_USER>root</DATABASE_USER>
                                <DATABASE_PASSWORD>root</DATABASE_PASSWORD>
                                <PORT>${das-postgres.port}</PORT>
                                <DOCKER_HOST_IP>${docker.container.das-postgres.ip}</DOCKER_HOST_IP>
                            </environmentVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-mssql</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-mssql</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-mssql</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <images>
                                <image>
                                    <name>microsoft/mssql-server-linux:2017-GA</name>
                                    <alias>das-mssql</alias>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <volumes>
                                            <bind>
                                                <volume>mssql_server_data:/var/opt/mssql/data</volume>
                                            </bind>
                                        </volumes>
                                        <env>
                                            <ACCEPT_EULA>Y</ACCEPT_EULA>
                                            <SA_PASSWORD>wso2das123#</SA_PASSWORD>
                                        </env>
                                        <ports>
                                            <port>${das-mssql.port}:1433</port>
                                        </ports>
                                        <wait>
                                            <log>Service Broker manager has started.</log>
                                            <time>120000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.19.1</version>
                        <executions>
                            <execution>
                                <id>integration-test-for-mssql</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-mssql</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <environmentVariables>
                                <DATABASE_TYPE>MSSQL</DATABASE_TYPE>
                                <DATABASE_USER>sa</DATABASE_USER>
                                <DATABASE_PASSWORD>wso2das123#</DATABASE_PASSWORD>
                                <PORT>${das-mssql.port}</PORT>
                                <DOCKER_HOST_IP>${docker.container.das-mssql.ip}</DOCKER_HOST_IP>
                            </environmentVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-oracle</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-oracle</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-oracle</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <images>
                                <image>
                                    <alias>das-oracle</alias>
                                    <name>dockerhub.private.wso2.com/sajithd-oracle-database:11.2.0.2-xe</name>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <env>
                                            <ORACLE_PWD>root</ORACLE_PWD>
                                        </env>
                                        <ports>
                                            <port>${das-oracle.port}:1521</port>
                                        </ports>
                                        <wait>
                                            <log>DATABASE IS READY TO USE!</log>
                                            <time>400000</time>
                                        </wait>
                                        <shmSize>2718281829</shmSize>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.19.1</version>
                        <executions>
                            <execution>
                                <id>integration-test-for-oracle</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-oracle</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <environmentVariables>
                                <DATABASE_TYPE>ORACLE</DATABASE_TYPE>
                                <DATABASE_USER>system</DATABASE_USER>
                                <DATABASE_PASSWORD>root</DATABASE_PASSWORD>
                                <PORT>${das-oracle.port}</PORT>
                                <DOCKER_HOST_IP>${docker.container.das-oracle.ip}</DOCKER_HOST_IP>
                            </environmentVariables>
                            <argLine>-Duser.timezone=GMT</argLine>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-db2</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-db2</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-db2</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <images>
                                <image>
                                    <alias>das-db2</alias>
                                    <name>dockerhub.private.wso2.com/sajithd-db2-database:latest</name>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <env>
                                            <DB2INST1_PASSWORD>db2inst1-pwd</DB2INST1_PASSWORD>
                                            <LICENSE>accept</LICENSE>
                                        </env>
                                        <cmd>
                                            <shell>su - db2inst1</shell>
                                            <shell>db2start</shell>
                                        </cmd>
                                        <ports>
                                            <port>${das-db2.port}:50000</port>
                                        </ports>
                                        <wait>
                                            <log>SQL1063N  DB2START processing was successful.</log>
                                            <time>10000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.19.1</version>
                        <executions>
                            <execution>
                                <id>integration-test-for-db2</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-db2</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <environmentVariables>
                                <DATABASE_TYPE>DB2</DATABASE_TYPE>
                                <DATABASE_USER>db2inst1</DATABASE_USER>
                                <DATABASE_PASSWORD>db2inst1-pwd</DATABASE_PASSWORD>
                                <PORT>${das-db2.port}</PORT>
                                <DOCKER_HOST_IP>${docker.container.das-db2.ip}</DOCKER_HOST_IP>
                            </environmentVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
