<?xml version="1.0"?>
<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>io.debezium</groupId>
        <artifactId>debezium-parent</artifactId>
        <version>1.8.0.Final</version>
	<relativePath>../debezium-parent/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>debezium-connector-oracle</artifactId>
    <name>Debezium Connector for Oracle</name>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>io.debezium</groupId>
            <artifactId>debezium-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.debezium</groupId>
            <artifactId>debezium-ddl-parser</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>connect-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
              <groupId>org.antlr</groupId>
              <artifactId>antlr4-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-client-hotrod</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan.protostream</groupId>
            <artifactId>protostream-processor</artifactId>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>io.debezium</groupId>
            <artifactId>debezium-core</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.debezium</groupId>
            <artifactId>debezium-embedded</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.debezium</groupId>
            <artifactId>debezium-embedded</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Required by VerifyRecord -->
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>kafka-connect-avro-converter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <adapter.name>logminer</adapter.name>
        <log.mining.buffer.type.name>memory</log.mining.buffer.type.name>

        <!--
        Specify properties that will be used for setting up the integration tests' Docker container.
        Note that the `dockerhost.ip` property is computed from the IP addrses of DOCKER_HOST, which will
        work on all platforms.  We'll set some of these system properties during integration testing.
        -->

        <!-- This should be kept in sync with the infinispan dependencies used -->
        <version.infinispan.server>12.1</version.infinispan.server>
        <oracle.infinispan.host>${docker.host.address}</oracle.infinispan.host>
        <oracle.infinispan.image>infinispan/server:${version.infinispan.server}</oracle.infinispan.image>
        <oracle.infinispan.port>11222</oracle.infinispan.port>
        <oracle.infinispan.user>admin</oracle.infinispan.user>
        <oracle.infinispan.password>admin</oracle.infinispan.password>
        <docker.skip>false</docker.skip>
        <docker.showLogs>true</docker.showLogs>
        <connector.assembly.ref>connector-distribution</connector.assembly.ref>
    </properties>

    <build>
        <resources>
            <!-- Apply the properties set in the POM to the resource files -->
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <includes>
                    <include>*</include>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>*</include>
                    <include>**/*</include>
                </includes>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties combine.children="append">
                        <property>
                            <name>database.connection.adapter</name>
                            <value>${adapter.name}</value>
                        </property>
                        <property>
                            <name>log.mining.buffer.type</name>
                            <value>${log.mining.buffer.type.name}</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skipTests>${skipITs}</skipTests>
                    <enableAssertions>true</enableAssertions>
                    <forkCount>1</forkCount>
                    <argLine>-Djava.library.path=${instantclient.dir} -Ddebezium.embedded.shutdown.pause.before.interrupt.ms=20000</argLine>
                    <systemPropertyVariables>
                        <database.connection.adapter>${adapter.name}</database.connection.adapter>
                        <log.mining.buffer.type>${log.mining.buffer.type.name}</log.mining.buffer.type>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!--
    Define several useful profiles
    -->
    <profiles>
        <profile>
            <id>xstream-dependency</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.oracle.instantclient</groupId>
                    <artifactId>xstreams</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>assembly</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.oracle.instantclient</groupId>
                    <artifactId>xstreams</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>io.debezium</groupId>
                                <artifactId>debezium-assembly-descriptors</artifactId>
                                <version>${project.version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>default</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <finalName>${project.artifactId}-${project.version}</finalName>
                                    <attach>true</attach>  <!-- we want attach & deploy these to Maven -->
                                    <descriptorRefs>
                                        <descriptorRef>${connector.assembly.ref}</descriptorRef>
                                    </descriptorRefs>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>quick</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>quick</name>
                </property>
            </activation>
            <properties>
                <skipITs>true</skipITs>
                <docker.skip>true</docker.skip>
            </properties>
        </profile>
        <profile>
            <!-- Allows CI to build Oracle without the xstream.jar dependency -->
            <id>oracle-ci</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration combine.self="override">
                            <excludes>
                                <exclude>**/io/debezium/connector/oracle/xstream/**</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>io.debezium</groupId>
                                <artifactId>debezium-assembly-descriptors</artifactId>
                                <version>${project.version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>default</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <finalName>${project.artifactId}-${project.version}</finalName>
                                    <attach>true</attach>  <!-- we want attach & deploy these to Maven -->
                                    <descriptorRefs>
                                        <descriptorRef>${connector.assembly.ref}</descriptorRef>
                                    </descriptorRefs>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>xstream</id>
            <properties>
                <adapter.name>xstream</adapter.name>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>com.oracle.instantclient</groupId>
                    <artifactId>xstreams</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
        <!-- This profile should be used for testing connector with Infinispan only -->
        <profile>
            <id>infinispan-buffer</id>
            <properties>
                <log.mining.buffer.type.name>infinispan</log.mining.buffer.type.name>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration combine.self="override">
                            <excludes>
                                <!-- When compiling with this profile, xstream is not added by default -->
                                <exclude>**/io/debezium/connector/oracle/xstream/**</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>infinispan-buffer-remote</id>
            <properties>
                <log.mining.buffer.type.name>infinispan_remote</log.mining.buffer.type.name>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration combine.self="override">
                            <excludes>
                                <!-- When compiling with this profile, xstream is not added by default -->
                                <exclude>**/io/debezium/connector/oracle/xstream/**</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <watchInterval>500</watchInterval>
                            <logDate>default</logDate>
                            <verbose>true</verbose>
                            <images>
                                <image>
                                    <!-- A docker image using Infinispan -->
                                    <name>${oracle.infinispan.image}</name>
                                    <run>
                                        <namingStrategy>none</namingStrategy>
                                        <env>
                                            <USER>${oracle.infinispan.user}</USER>
                                            <PASS>${oracle.infinispan.password}</PASS>
                                        </env>
                                        <ports>
                                            <port>${oracle.infinispan.port}:11222</port>
                                        </ports>
                                        <log>
                                            <prefix>infinispan</prefix>
                                            <enabled>${docker.showLogs}</enabled>
                                            <color>green</color>
                                        </log>
                                        <wait>
                                            <time>60000</time> <!-- 60 seconds max -->
                                            <log>Infinispan Server [0-9a-zA-z.]* started</log>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                        <!--
                        Connect this plugin to the maven lifecycle around the integration-test phase:
                        start the container in pre-integration-test and stop it in post-integration-test.
                        -->
                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
