<?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.9.6.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>ch.qos.logback</groupId>
            <artifactId>logback-classic</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>

        <!-- Used for unit testing with Kafka -->
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_${version.kafka.scala}</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <adapter.name>logminer</adapter.name>
        <log.mining.buffer.type.name>memory</log.mining.buffer.type.name>
        <version.oracle.server>19.3.0</version.oracle.server>

        <!--
        By default, the Oracle module's tests are not executed but only compiled.
        In order to execute tests, the profile "oracle-tests" must be explicitly toggled.
        -->
        <skipITs>true</skipITs>

        <!--
        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-compiler-plugin</artifactId>
                <configuration>
                    <!--
                    By default we exclude the Xstream sources.
                    To enable Xstream support, use the "oracle-xstream" profile
                     -->
                    <excludes>
                        <exclude>**/io/debezium/connector/oracle/xstream/**</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <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: oracle-tests
        This specifically enables the execution of all integration tests.
        By default, integration tests are only compiled but are not executed.
        -->
        <profile>
            <id>oracle-tests</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <skipITs>false</skipITs>
            </properties>
        </profile>
        <!--
        Profile: oracle-xstream
        This is a multi-faceted profile that controls several key points:
            1. Adds the Oracle Instant Client & Xstream dependencies to the module
            2. Includes the Xstream sources into the build, which are otherwise excluded
            3. Enables the ability to execute the test suite for the Xstream adapter
        -->
        <profile>
            <id>oracle-xstream</id>
            <properties>
                <!-- Point (3) enables the xstream adapter for tests -->
                <adapter.name>xstream</adapter.name>
            </properties>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <!-- Point (1) add the Xstream dependencies -->
            <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-compiler-plugin</artifactId>
                        <configuration combine.self="override">
                            <!-- Point (2) add the Xstream sources back into the module -->
                            <includes>
                                <include>**</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- Enables all sources, useful for IDE build or releases -->
        <profile>
            <id>oracle-all</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-compiler-plugin</artifactId>
                        <configuration combine.self="override">
                            <includes>
                                <include>**</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </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-compiler-plugin</artifactId>
                        <configuration combine.self="override">
                            <!-- include xstream back into the module on assembly builds -->
                            <includes>
                                <include>**</include>
                            </includes>
                        </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>quick</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>quick</name>
                </property>
            </activation>
            <properties>
                <skipITs>true</skipITs>
                <docker.skip>true</docker.skip>
            </properties>
        </profile>
        <profile>
            <id>oracle-docker</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                      <groupId>io.fabric8</groupId>
                      <artifactId>docker-maven-plugin</artifactId>
                      <configuration>
                        <watchInterval>500</watchInterval>
                        <logDate>default</logDate>
                        <verbose>true</verbose>
                        <!--autoPull>always</autoPull-->
                        <images>
                          <!-- A container for the data server replica set -->
                          <image>
                            <name>quay.io/rh_integration/dbz-oracle:${version.oracle.server}</name>
                            <alias>oracle1</alias>
                            <run>
                              <namingStrategy>alias</namingStrategy>
                              <ports>
                                <port>1521:1521</port> 
                              </ports>
                              <log>
                                <prefix>oracle1</prefix>
                                <enabled>true</enabled>
                                <color>yellow</color>
                              </log>
                              <wait>
                                <log>DONE: Executing user defined scripts</log>
                                <time>120000</time> <!-- 2 minutes max -->
                              </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>build</goal>
                            <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>
        <!-- This profile should be used for testing connector with Infinispan only -->
        <profile>
            <id>infinispan-buffer</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <log.mining.buffer.type.name>infinispan</log.mining.buffer.type.name>
            </properties>
            <!-- todo: when using this profile, enforce oracle-xstream being mutually exclusive -->
        </profile>
        <profile>
            <id>infinispan-buffer-remote</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <log.mining.buffer.type.name>infinispan_remote</log.mining.buffer.type.name>
            </properties>
            <!-- todo: when using this profile, enforce oracle-xstream being mutually exclusive -->
            <build>
                <plugins>
                    <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>
