<?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>3.0.8.Final-redhat-00004</version>
        <relativePath>../debezium-parent/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>debezium-connector-mariadb</artifactId>
    <name>Debezium Connector for MariaDB</name>
    <packaging>jar</packaging>

    <dependencies>
        <!-- Runtime dependencies -->
        <dependency>
            <groupId>io.debezium</groupId>
            <artifactId>debezium-connector-binlog</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>connect-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Testing dependencies -->
        <dependency>
            <groupId>io.debezium</groupId>
            <artifactId>debezium-connector-binlog</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <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>
            <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-testing-testcontainers</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-launcher</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mil.nga</groupId>
            <artifactId>wkb</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>kafka-connect-avro-converter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.apicurio</groupId>
            <artifactId>apicurio-registry-utils-converter</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-jboss-logmanager</artifactId>
                    <groupId>org.jboss.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mariadb</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</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>
        <!--
        Specify the properties for the various Docker containers.
        -->
        <mariadb.server.image.source>mirror.gcr.io/library/mariadb</mariadb.server.image.source>
        <version.mariadb.server>11.4.3</version.mariadb.server>
        <mariadb.user>mysqluser</mariadb.user>
        <mariadb.password>mysqlpw</mariadb.password>
        <mariadb.replica.user>mysqlreplica</mariadb.replica.user>
        <mariadb.replica.password>mysqlpw</mariadb.replica.password>
        <mariadb.port>3306</mariadb.port>
        <mariadb.percona.port>3306</mariadb.percona.port>
        <mariadb.gtid.port>3306</mariadb.gtid.port>
        <mariadb.gtid.replica.port>3306</mariadb.gtid.replica.port>
        <mariadb.ssl.port>3306</mariadb.ssl.port>
        <mariadb.replica.port>3306</mariadb.replica.port> <!-- by default use primary as 'replica' -->
        <mariadb.init.timeout>60000</mariadb.init.timeout> <!-- 60 seconds -->
        <apicurio.image>quay.io/apicurio/apicurio-registry-mem</apicurio.image>
        <apicurio.port>8080</apicurio.port>
        <apicurio.init.timeout>60000</apicurio.init.timeout> <!-- 60 seconds -->
        <mariadb.replica.fileset.path>${project.basedir}/src/test/docker/init-replica</mariadb.replica.fileset.path>
        <!--
        By default, we should use the docker image maintained by the MariaDB team. This property is changed with different profiles.
        However, we run one container with GTIDs and one without.
        -->
        <docker.dbs>debezium/mariadb-server-test-database</docker.dbs>
        <docker.filter>${docker.dbs}</docker.filter>
        <docker.skip>false</docker.skip>
        <docker.initimage>rm -f /etc/localtime; ln -s /usr/share/zoneinfo/Pacific/Samoa /etc/localtime</docker.initimage>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    <watchInterval>500</watchInterval>
                    <logDate>default</logDate>
                    <verbose>true</verbose>
                    <imagePullPolicy>IfNotPresent</imagePullPolicy>
                    <images>
                        <!--
                        Images based on "${mariadb.server.image.source}" Docker image
                        -->
                        <image>
                            <!-- A Docker image using a partial MariaDB installation maintained by MariaDB team. -->
                            <name>debezium/mariadb-server-test-database</name>
                            <run>
                                <namingStrategy>none</namingStrategy>
                                <env>
                                    <MARIADB_ROOT_PASSWORD>debezium-rocks</MARIADB_ROOT_PASSWORD>
                                    <MARIADB_DATABASE>mysql</MARIADB_DATABASE> <!-- database created upon init -->
                                    <MARIADB_USER>${mariadb.user}</MARIADB_USER>
                                    <MARIADB_PASSWORD>${mariadb.password}</MARIADB_PASSWORD>
                                    <TZ>UTC</TZ>
                                </env>
                                <ports>
                                    <port>${mariadb.port}:3306</port>
                                </ports>
                                <log>
                                    <prefix>mariadb</prefix>
                                    <enabled>true</enabled>
                                    <color>yellow</color>
                                </log>
                                <wait>
                                    <log>(MariaDB) init process done. Ready for start up.(?s)(.*)(mariadbd): ready for connections.</log>
                                    <time>${mariadb.init.timeout}</time>
                                </wait>
                            </run>
                            <build>
                                <from>${mariadb.server.image.source}:${version.mariadb.server}</from>
                                <runCmds>
                                    <run>${docker.initimage}</run>
                                </runCmds>
                                <assembly>
                                    <inline>
                                        <fileSets>
                                            <fileSet>
                                                <directory>${project.basedir}/src/test/docker/server</directory>
                                                <includes>
                                                    <include>my.cnf</include>
                                                </includes>
                                                <outputDirectory>etc/mysql</outputDirectory>
                                            </fileSet>
                                            <fileSet>
                                                <directory>${project.basedir}/src/test/docker/init</directory>
                                                <outputDirectory>docker-entrypoint-initdb.d</outputDirectory>
                                            </fileSet>
                                        </fileSets>
                                    </inline>
                                    <targetDir>/</targetDir>
                                </assembly>
                            </build>
                            <external>
                                <type>properties</type>
                                <mode>override</mode>
                            </external>
                        </image>
                        <image>
                            <!-- A Docker image using a partial MariaDB installation maintained by MariaDB team
                             that enable MariaDB ssl connection -->
                            <name>debezium/mariadb-server-test-database-ssl</name>
                            <run>
                                <namingStrategy>none</namingStrategy>
                                <env>
                                    <MARIADB_ROOT_PASSWORD>debezium-rocks</MARIADB_ROOT_PASSWORD>
                                    <MARIADB_DATABASE>mysql</MARIADB_DATABASE> <!-- database created upon init -->
                                    <MARIADB_USER>${mariadb.user}</MARIADB_USER>
                                    <MARIADB_PASSWORD>${mariadb.password}</MARIADB_PASSWORD>
                                    <TZ>UTC</TZ>
                                </env>
                                <ports>
                                    <port>${mariadb.ssl.port}:3306</port>
                                </ports>
                                <volumes>
                                    <bind>
                                        <volume>${project.basedir}/src/test/resources/ssl-certs:/etc/certs</volume>
                                    </bind>
                                </volumes>
                                <log>
                                    <prefix>mariadb</prefix>
                                    <enabled>true</enabled>
                                    <color>yellow</color>
                                </log>
                                <wait>
                                    <log>(MariaDB) init process done. Ready for start up.(?s)(.*)(mariadbd): ready for connections.</log>
                                    <time>${mariadb.init.timeout}</time>
                                </wait>
                            </run>
                            <build>
                                <from>${mariadb.server.image.source}:${version.mariadb.server}</from>
                                <runCmds>
                                    <run>${docker.initimage}</run>
                                </runCmds>
                                <assembly>
                                    <inline>
                                        <fileSets>
                                            <fileSet>
                                                <directory>${project.basedir}/src/test/docker/server-ssl</directory>
                                                <includes>
                                                    <include>my.cnf</include>
                                                </includes>
                                                <outputDirectory>etc/mysql</outputDirectory>
                                            </fileSet>
                                            <fileSet>
                                                <directory>${project.basedir}/src/test/docker/init</directory>
                                                <outputDirectory>docker-entrypoint-initdb.d</outputDirectory>
                                            </fileSet>
                                            <fileSet>
                                                <directory>${project.basedir}/src/test/docker/init-ssl</directory>
                                                <outputDirectory>docker-entrypoint-initdb.d</outputDirectory>
                                            </fileSet>
                                        </fileSets>
                                    </inline>
                                    <targetDir>/</targetDir>
                                </assembly>
                            </build>
                            <external>
                                <type>properties</type>
                                <mode>override</mode>
                            </external>
                        </image>
                        <image>
                            <!-- A Docker image using a partial MariaDB installation maintained by MariaDB team. -->
                            <name>debezium/mariadb-server-gtids-test-database</name>
                            <alias>database-gtids</alias>
                            <run>
                                <namingStrategy>alias</namingStrategy>
                                <env>
                                    <MARIADB_ROOT_PASSWORD>debezium-rocks</MARIADB_ROOT_PASSWORD>
                                    <MARIADB_DATABASE>mysql</MARIADB_DATABASE> <!-- database created upon init -->
                                    <MARIADB_USER>${mariadb.user}</MARIADB_USER>
                                    <MARIADB_PASSWORD>${mariadb.password}</MARIADB_PASSWORD>
                                    <TZ>UTC</TZ>
                                </env>
                                <ports>
                                    <port>${mariadb.gtid.port}:3306</port>
                                </ports>
                                <log>
                                    <prefix>mariadb-gtids</prefix>
                                    <enabled>true</enabled>
                                    <color>cyan</color>
                                </log>
                                <wait>
                                    <log>(MariaDB) init process done. Ready for start up.(?s)(.*)(mariadbd): ready for connections.</log>
                                    <time>${mariadb.init.timeout}</time>
                                </wait>
                            </run>
                            <build>
                                <from>${mariadb.server.image.source}:${version.mariadb.server}</from>
                                <runCmds>
                                    <run>${docker.initimage}</run>
                                </runCmds>
                                <assembly>
                                    <inline>
                                        <fileSets>
                                            <fileSet>
                                                <directory>${project.basedir}/src/test/docker/server-gtids</directory>
                                                <includes>
                                                    <include>my.cnf</include>
                                                </includes>
                                                <outputDirectory>etc/mysql</outputDirectory>
                                            </fileSet>
                                            <fileSet>
                                                <directory>${project.basedir}/src/test/docker/init</directory>
                                                <outputDirectory>docker-entrypoint-initdb.d</outputDirectory>
                                            </fileSet>
                                        </fileSets>
                                    </inline>
                                    <targetDir>/</targetDir>
                                </assembly>
                            </build>
                            <external>
                                <type>properties</type>
                                <mode>override</mode>
                            </external>
                        </image>
                        <image>
                            <!--
                            A Docker image using a MariaDB installation maintained by MariaDB team
                            that is a replica of `debezium/mariadb-server-gtids-test-database`
                            -->
                            <name>debezium/mariadb-server-gtids-test-database-replica</name>
                            <run>
                                <namingStrategy>none</namingStrategy>
                                <env>
                                    <MARIADB_ROOT_PASSWORD>debezium-rocks</MARIADB_ROOT_PASSWORD>
                                    <MARIADB_USER>${mariadb.replica.user}</MARIADB_USER>
                                    <MARIADB_PASSWORD>${mariadb.replica.password}</MARIADB_PASSWORD>
                                    <TZ>UTC</TZ>
                                </env>
                                <links>
                                    <link>database-gtids</link>
                                </links>
                                <ports>
                                    <port>${mariadb.gtid.replica.port}:3306</port>
                                </ports>
                                <log>
                                    <prefix>mariadb-gtids-replica</prefix>
                                    <enabled>true</enabled>
                                    <color>magenta</color>
                                </log>
                                <wait>
                                    <log>(MariaDB) init process done. Ready for start up.(?s)(.*)(mariadbd): ready for connections.</log>
                                    <time>${mariadb.init.timeout}</time>
                                </wait>
                            </run>
                            <build>
                                <from>${mariadb.server.image.source}:${version.mariadb.server}</from>
                                <runCmds>
                                    <run>${docker.initimage}</run>
                                </runCmds>
                                <assembly>
                                    <inline>
                                        <fileSets>
                                            <fileSet>
                                                <directory>${project.basedir}/src/test/docker/server-replica</directory>
                                                <includes>
                                                    <include>my.cnf</include>
                                                </includes>
                                                <outputDirectory>etc/mysql</outputDirectory>
                                            </fileSet>
                                            <fileSet>
                                                <directory>${mariadb.replica.fileset.path}</directory>
                                                <outputDirectory>docker-entrypoint-initdb.d</outputDirectory>
                                            </fileSet>
                                        </fileSets>
                                    </inline>
                                    <targetDir>/</targetDir>
                                </assembly>
                            </build>
                            <external>
                                <type>properties</type>
                                <mode>override</mode>
                            </external>
                        </image>
                        <image>
                            <name>${apicurio.image}:${version.apicurio}</name>
                            <run>
                                <namingStrategy>none</namingStrategy>
                                <ports>
                                    <port>${apicurio.port}:8080</port>
                                </ports>
                                <log>
                                    <prefix>apicurio</prefix>
                                    <enabled>true</enabled>
                                    <color>blue</color>
                                </log>
                                <wait>
                                    <log>.*apicurio-registry-app.*started in.*</log>
                                    <time>${apicurio.init.timeout}</time>
                                </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>
            <!--
            Unlike surefire, the failsafe plugin ensures 'post-integration-test' phase always runs, even
            when there are failed integration tests. We rely upon this to always shut down the Docker container
            after the integration tests (defined as '*IT.java') are run.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <skipTests>${skipITs}</skipTests>
                    <enableAssertions>true</enableAssertions>
                    <systemPropertyVariables>
                        <!-- Make these available to the tests via system properties -->
                        <database.hostname>${docker.host.address}</database.hostname>
                        <database.port>${mariadb.port}</database.port>
                        <database.user>${mariadb.user}</database.user>
                        <database.password>${mariadb.password}</database.password>
                        <database.replica.hostname>${docker.host.address}</database.replica.hostname>
                        <database.replica.port>${mariadb.replica.port}</database.replica.port>
                        <!-- Specifies which driver to use for the tests -->
                        <skipLongRunningTests>${skipLongRunningTests}</skipLongRunningTests>
                        <database.ssl.mode>disable</database.ssl.mode>
                    </systemPropertyVariables>
                    <runOrder>${runOrder}</runOrder>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>io.debezium</groupId>
                <artifactId>debezium-schema-generator</artifactId>
                <version>${project.version}</version>
                <executions>
                    <execution>
                        <id>generate-connector-metadata</id>
                        <goals>
                            <goal>generate-api-spec</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/META-INF/resources/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <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>false</filtering>
                <includes>
                    <include>*</include>
                    <include>**/*</include>
                </includes>
            </testResource>
        </testResources>
    </build>
    <!--
    Define several useful profiles
    -->
    <profiles>
        <!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              This assembly profile is used during official builds. In addition to
              compiling, and running the unit and integration tests like the non-assembly
              profiles, this profile creates additional (like the connector plugin archives),
              starts up all three Docker containers (normal MariaDB, MariaDB+GTIDs, and alt-MariaDB)
              and runs the integration tests against each of them.

              To use, specify "-Passembly" on the Maven command line.
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        <profile>
            <id>assembly</id>
            <activation>
            </activation>
            <properties>
                <!-- Run multiple images at the same time, but use different ports for all MariaDB servers -->
                <docker.dbs>
                    debezium/mariadb-server-test-database,debezium/mariadb-server-gtids-test-database,debezium/mariadb-server-gtids-test-database-replica,debezium/mariadb-server-test-database-ssl
                </docker.dbs>
                <mariadb.port>4301</mariadb.port>
                <mariadb.gtid.port>4302</mariadb.gtid.port>
                <mariadb.gtid.replica.port>4303</mariadb.gtid.replica.port>
                <mariadb.percona.port>4304</mariadb.percona.port>
                <mariadb.ssl.port>4305</mariadb.ssl.port>
            </properties>
            <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>${assembly.descriptor}</descriptorRef>
                                    </descriptorRefs>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!--
                    Override the failsafe plugin to run the integration tests for each set of databases.
                    But make sure each database server is used only once ...
                    -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${version.failsafe.plugin}</version>
                        <configuration>
                            <skipTests>${skipITs}</skipTests>
                            <enableAssertions>true</enableAssertions>
                            <systemPropertyVariables>
                                <!-- Make these available to the tests via system properties -->
                                <database.hostname>${docker.host.address}</database.hostname>
                                <database.user>${mariadb.user}</database.user>
                                <database.password>${mariadb.password}</database.password>
                                <database.replica.hostname>${docker.host.address}</database.replica.hostname>
                                <database.replica.user>${mariadb.replica.user}</database.replica.user>
                                <database.replica.password>${mariadb.replica.password}</database.replica.password>
                                <database.port>${mariadb.port}</database.port>
                                <database.replica.port>${mariadb.port}</database.replica.port>
                                <database.ssl.mode>disable</database.ssl.mode>
                                <!-- Specifies which driver to use for the tests -->
                                <skipLongRunningTests>false</skipLongRunningTests>
                                <isAssemblyProfileActive>true</isAssemblyProfileActive>
                            </systemPropertyVariables>
                            <runOrder>${runOrder}</runOrder>
                        </configuration>
                        <executions>
                            <!-- First run the integration tests with the non-GTID server alone -->
                            <execution>
                                <id>integration-test-mariadb</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <systemPropertyVariables>
                                        <!-- same port for both, since we're only running one server -->
                                        <database.port>${mariadb.port}</database.port>
                                        <database.replica.port>${mariadb.port}</database.replica.port>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                            <!-- Then run the integration tests with the GTID server + replica server -->
                            <execution>
                                <id>integration-test-mariadb-gtids-with-replica</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <systemPropertyVariables>
                                        <database.port>${mariadb.gtid.port}</database.port>
                                        <database.replica.port>${mariadb.gtid.replica.port}</database.replica.port>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                            <!-- SSL -->
                            <execution>
                                <id>integration-test-ssl</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <systemPropertyVariables>
                                        <database.ssl.mode>verify-ca</database.ssl.mode>
                                        <database.ssl.truststore>${project.basedir}/src/test/resources/ssl/truststore</database.ssl.truststore>
                                        <database.ssl.truststore.password>debezium</database.ssl.truststore.password>
                                        <database.ssl.keystore>${project.basedir}/src/test/resources/ssl/keystore</database.ssl.keystore>
                                        <database.ssl.keystore.password>debezium</database.ssl.keystore.password>
                                        <!-- same port for both, since we're only running one server -->
                                        <database.port>${mariadb.ssl.port}</database.port>
                                        <database.replica.port>${mariadb.ssl.port}</database.replica.port>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                            <execution>
                                <id>verify</id>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              Do not perform any Docker-related functionality
              To use, specify "-DskipITs" on the Maven command line.
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        <profile>
            <id>skip-integration-tests</id>
            <activation>
                <property>
                    <name>skipITs</name>
                </property>
            </activation>
            <properties>
                <docker.skip>true</docker.skip>
            </properties>
        </profile>
        <profile>
            <id>quick</id>
            <activation>
                <property>
                    <name>quick</name>
                </property>
            </activation>
            <properties>
                <skipITs>true</skipITs>
                <docker.skip>true</docker.skip>
            </properties>
        </profile>
        <!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              Use the alternative Docker image for MariaDB.
              To use, specify "-Dmariadb-gtids" or -Pmariadb-gtids on the Maven command line.
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        <profile>
            <id>mariadb-gtids</id>
            <activation>
                <property>
                    <name>mariadb-gtids</name>
                </property>
            </activation>
            <properties>
                <!-- Docker properties -->
                <docker.dbs>debezium/mariadb-server-gtids-test-database</docker.dbs>
                <!-- Integration test properties -->
                <database.port>${mariadb.gtid.port}</database.port>
                <database.replica.port>${mariadb.gtid.port}</database.replica.port>
            </properties>
        </profile>
        <!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Use the Docker image for a MariaDB replica of another MariaDB server
        configured to use GTIDs. To use, specify "-Dmariadb-replica"
        or -Pmariadb-replica on the Maven command line.
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

        <profile>
            <id>mariadb-replica</id>
            <activation>
                <property>
                    <name>mariadb-replica</name>
                </property>
            </activation>
            <properties>
                <!-- Docker properties -->
                <mariadb.gtid.port>3306</mariadb.gtid.port>
                <mariadb.gtid.replica.port>4306</mariadb.gtid.replica.port>
                <docker.dbs>debezium/mariadb-server-gtids-test-database,debezium/mariadb-server-gtids-test-database-replica</docker.dbs>
                <!-- Integration test properties -->
                <database.port>${mariadb.gtid.port}</database.port>
                <database.replica.port>${mariadb.gtid.replica.port}</database.replica.port>
            </properties>
        </profile>
        <!--  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Use the alternative Docker image for MariaDB.
        To use, specify "-Dmariadb-ssl" or -Pmariadb-ssl on the Maven command line.
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        <profile>
            <id>mariadb-ssl</id>
            <activation>
                <property>
                    <name>mariadb-ssl</name>
                </property>
            </activation>
            <properties>
                <!-- Docker properties -->
                <docker.dbs>debezium/mariadb-server-test-database-ssl</docker.dbs>
                <!-- Integration test properties -->
                <database.port>${mariadb.ssl.port}</database.port>
                <database.replica.port>${mariadb.ssl.port}</database.replica.port>
                <docker.initimage>rm -f /etc/localtime; ln -s /usr/share/zoneinfo/Pacific/Pago_Pago /etc/localtime</docker.initimage>
            </properties>
        </profile>
        <profile>
            <id>apicurio</id>
            <activation>
                <property>
                    <name>apicurio</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <use.apicurio>true</use.apicurio>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <docker.filter>${docker.dbs},${apicurio.image}:${version.apicurio}</docker.filter>
            </properties>
        </profile>

        <!-- CI configurations, used for parallel execution on GH actions -->

        <!-- Runs tests only with standalone -->
        <profile>
            <id>mariadb-ci</id>
            <activation>
            </activation>
            <properties>
                <docker.dbs>debezium/mariadb-server-test-database</docker.dbs>
            </properties>
            <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>${assembly.descriptor}</descriptorRef>
                                    </descriptorRefs>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${version.failsafe.plugin}</version>
                        <configuration>
                            <skipTests>${skipITs}</skipTests>
                            <enableAssertions>true</enableAssertions>
                            <systemPropertyVariables>
                                <!-- Make these available to the tests via system properties -->
                                <database.hostname>${docker.host.address}</database.hostname>
                                <database.user>${mariadb.user}</database.user>
                                <database.password>${mariadb.password}</database.password>
                                <database.replica.hostname>${docker.host.address}</database.replica.hostname>
                                <database.replica.user>${mariadb.replica.user}</database.replica.user>
                                <database.replica.password>${mariadb.replica.password}</database.replica.password>
                                <database.port>${mariadb.port}</database.port>
                                <database.replica.port>${mariadb.port}</database.replica.port>
                                <database.ssl.mode>disable</database.ssl.mode>
                                <!-- Specifies which driver to use for the tests -->
                                <skipLongRunningTests>false</skipLongRunningTests>
                                <isAssemblyProfileActive>true</isAssemblyProfileActive>
                            </systemPropertyVariables>
                            <runOrder>${runOrder}</runOrder>
                        </configuration>
                        <executions>
                            <execution>
                                <id>integration-test-mariadb</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Runs tests only with GTID setup -->
        <profile>
            <id>mariadb-ci-gtids</id>
            <activation>
            </activation>
            <properties>
                <docker.dbs>debezium/mariadb-server-gtids-test-database,debezium/mariadb-server-gtids-test-database-replica</docker.dbs>
                <mariadb.gtid.port>4302</mariadb.gtid.port>
                <mariadb.gtid.replica.port>4303</mariadb.gtid.replica.port>
            </properties>
            <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>${assembly.descriptor}</descriptorRef>
                                    </descriptorRefs>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${version.failsafe.plugin}</version>
                        <configuration>
                            <skipTests>${skipITs}</skipTests>
                            <enableAssertions>true</enableAssertions>
                            <systemPropertyVariables>
                                <!-- Make these available to the tests via system properties -->
                                <database.hostname>${docker.host.address}</database.hostname>
                                <database.user>${mariadb.user}</database.user>
                                <database.password>${mariadb.password}</database.password>
                                <database.replica.hostname>${docker.host.address}</database.replica.hostname>
                                <database.replica.user>${mariadb.replica.user}</database.replica.user>
                                <database.replica.password>${mariadb.replica.password}</database.replica.password>
                                <database.port>${mariadb.gtid.port}</database.port>
                                <database.replica.port>${mariadb.gtid.replica.port}</database.replica.port>
                                <database.ssl.mode>disable</database.ssl.mode>
                                <!-- Specifies which driver to use for the tests -->
                                <skipLongRunningTests>false</skipLongRunningTests>
                                <isAssemblyProfileActive>true</isAssemblyProfileActive>
                            </systemPropertyVariables>
                            <runOrder>${runOrder}</runOrder>
                        </configuration>
                        <executions>
                            <execution>
                                <id>integration-test-mariadb-gtids-with-replica</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Runs tests only with SSL setup -->
        <profile>
            <id>mariadb-ci-ssl</id>
            <activation>
            </activation>
            <properties>
                <docker.dbs>debezium/mariadb-server-test-database-ssl</docker.dbs>
            </properties>
            <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>${assembly.descriptor}</descriptorRef>
                                    </descriptorRefs>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${version.failsafe.plugin}</version>
                        <configuration>
                            <skipTests>${skipITs}</skipTests>
                            <enableAssertions>true</enableAssertions>
                            <systemPropertyVariables>
                                <!-- Make these available to the tests via system properties -->
                                <database.hostname>${docker.host.address}</database.hostname>
                                <database.user>${mariadb.user}</database.user>
                                <database.password>${mariadb.password}</database.password>
                                <database.replica.hostname>${docker.host.address}</database.replica.hostname>
                                <database.replica.user>${mariadb.replica.user}</database.replica.user>
                                <database.replica.password>${mariadb.replica.password}</database.replica.password>
                                <database.port>${mariadb.port}</database.port>
                                <database.replica.port>${mariadb.port}</database.replica.port>
                                <database.ssl.mode>verify-ca</database.ssl.mode>
                                <!-- Specifies which driver to use for the tests -->
                                <skipLongRunningTests>false</skipLongRunningTests>
                                <isAssemblyProfileActive>true</isAssemblyProfileActive>
                                <database.ssl.truststore>${project.basedir}/src/test/resources/ssl/truststore</database.ssl.truststore>
                                <database.ssl.truststore.password>debezium</database.ssl.truststore.password>
                                <database.ssl.keystore>${project.basedir}/src/test/resources/ssl/keystore</database.ssl.keystore>
                                <database.ssl.keystore.password>debezium</database.ssl.keystore.password>
                            </systemPropertyVariables>
                            <runOrder>${runOrder}</runOrder>
                        </configuration>
                        <executions>
                            <execution>
                                <id>integration-test-ssl</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>
</project>
