<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.liquibase.ext</groupId>
    <artifactId>liquibase-percona</artifactId>
    <version>4.26.0</version>
    <name>Liquibase Percona Extension</name>
    <description>A Liquibase extension that makes use of the percona toolkit</description>
    <url>https://liquibase.jira.com/wiki/display/CONTRIB/Percona+Online+Schema+Change</url>
    <organization>
        <name>Liquibase.org</name>
        <url>http://www.liquibase.org</url>
    </organization>
    <inceptionYear>2014</inceptionYear>
    <licenses>
        <license>
            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
            <name>Apache License, Version 2.0</name>
        </license>
    </licenses>
    <issueManagement>
        <url>https://github.com/liquibase/liquibase-percona/issues</url>
        <system>github</system>
    </issueManagement>
    <scm>
        <connection>scm:git:http://github.com/liquibase/liquibase-percona.git</connection>
        <url>https://github.com/liquibase/liquibase-percona</url>
        <tag>HEAD</tag>
    </scm>
    <developers>
        <developer>
            <id>adangel</id>
            <name>Andreas Dangel</name>
            <email>andreas.dangel at adangel.org</email>
            <timezone>+1</timezone>
        </developer>
    </developers>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Note: this needs to be updated for each release: "date -u -Iseconds" -->
        <project.build.outputTimestamp>2024-03-28T07:01:34Z</project.build.outputTimestamp>

        <java.version>1.8</java.version>
        <liquibase.version>4.26.0</liquibase.version>
        <mysql.connector.version>8.3.0</mysql.connector.version>
        <mariadb.connector.version>3.3.3</mariadb.connector.version>
        <percona.toolkit.version>3.5.5</percona.toolkit.version>

        <config_host>127.0.0.1</config_host>
        <!--
        Docker will choose a random free port for the mysql instance
        and the docker-maven-plugin will store it in this property.
        If you want a fixed port, just define the property here.
        <config_port>3306</config_port>

        The same for mariadb
        <config_port_mariadb>3307</config_port_mariadb>
         -->
        <config_user>root</config_user>
        <config_password>root</config_password>
        <config_dbname>testdb</config_dbname>
        <mysql_image>mysql:8.2</mysql_image>
        <mariadb_image>mariadb:11</mariadb_image>

        <docker.removeVolumes>true</docker.removeVolumes>
        <percona.toolkit.usecache>true</percona.toolkit.usecache>
        <percona.toolkit.cachedir>${project.basedir}/.cache</percona.toolkit.cachedir>
        <itPrebuildHookScript>../sharedScripts/setup</itPrebuildHookScript>
        <sonar.organization>liquibase</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <sonar.scm.provider>git</sonar.scm.provider>
        <sonar.qualitygate.wait>true</sonar.qualitygate.wait>
        <sonar.sources>src/main/java</sonar.sources>
        <sonar.tests>src/test/java</sonar.tests>
        <sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
        <sonar.projectKey>liquibase_${project.artifactId}</sonar.projectKey>
        <sonar.projectDescription>${project.description}</sonar.projectDescription>
        <copy-rename-maven-plugin.version>1.0.1</copy-rename-maven-plugin.version>
        <jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>
        <maven-source-plugin.version>3.3.0</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>${liquibase.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>2.2</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.10.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>${mysql.connector.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <version>${mariadb.connector.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jdbc</artifactId>
            <version>10.1.20</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.12.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
            </resource>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <includes>
                    <include>dbchangelog-ext-liquibase-percona.xsd</include>
                </includes>
                <targetPath>raw.githubusercontent.com/liquibase/liquibase-percona/main/src/main/resources</targetPath>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <!--
                  for reproducible builds, maven-jar-plugin, maven-source-plugin, maven-assembly-plugin
                  and maven-javadoc-plugin >= 3.2.0 is required.
                  See https://maven.apache.org/guides/mini/guide-reproducible-builds.html
                 -->
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.13.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>3.4.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.2.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-invoker-plugin</artifactId>
                    <version>3.6.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.3.0</version> <!-- for reproducible builds: >= 3.3.0 -->
                </plugin>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.6.3</version> <!-- for reproducible builds: >= 3.6.3 -->
                </plugin>
                <plugin>
                    <artifactId>maven-pmd-plugin</artifactId>
                    <version>3.21.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.3.0</version> <!-- for reproducible builds: >= 3.2.0 -->
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.2.5</version>
                </plugin>
                <plugin>
                    <groupId>com.github.spotbugs</groupId>
                    <artifactId>spotbugs-maven-plugin</artifactId>
                    <version>4.8.3.1</version>
                    <configuration>
                        <excludeFilterFile>spotbugs-exclusions.xml</excludeFilterFile>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>0.44.0</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.5.0</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.13</version>
                </plugin>
            </plugins>
        </pluginManagement>
    
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <optimize>true</optimize>
                    <debug>true</debug>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce-java</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>${java.version}</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-pmd-plugin</artifactId>
                <configuration>
                    <targetJdk>${java.version}</targetJdk>
                    <printFailingErrors>true</printFailingErrors>
                    <linkXRef>false</linkXRef>
                </configuration>
                <executions>
                    <execution>
                        <id>pmd</id>
                        <goals>
                            <goal>check</goal>
                            <goal>cpd-check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <reportFormat>plain</reportFormat>
                </configuration>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*Test.java</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>integration-tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>spotbugs</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <serverId>sonatype-nexus-staging</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>sonatype-nexus-staging</id>
            <name>Nexus Release Repository</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
        <snapshotRepository>
            <id>sonatype-nexus-staging</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>

    <profiles>
        <profile>
            <id>coverage</id>
            <activation>
                <property>
                    <name>env.CI</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>${jacoco-maven-plugin.version}</version>
                        <executions>
                            <execution>
                              <goals>
                                <goal>prepare-agent</goal>
                              </goals>
                            </execution>
                            <execution>
                              <id>report</id>
                              <phase>test</phase>
                              <goals>
                                <goal>report</goal>
                              </goals>
                            </execution>
                          </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven-source-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <configuration>
                            <author>false</author>
                            <doctitle>Liquibase ${project.name} ${project.version} API</doctitle>
                            <quiet>true</quiet>
                            <doclint>none</doclint>
                            <encoding>UTF-8</encoding>
                            <jarOutputDirectory>${project.build.directory}</jarOutputDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>jar-javadoc</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.coderplus.maven.plugins</groupId>
                        <artifactId>copy-rename-maven-plugin</artifactId>
                        <version>${copy-rename-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>copy</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <fileSets>
                                        <fileSet>
                                            <sourceFile>${project.basedir}/pom.xml</sourceFile>
                                            <destinationFile>${project.basedir}/target/${project.artifactId}-${project.version}.pom</destinationFile>
                                        </fileSet>
                                    </fileSets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- Required for deployment to Sonatype -->
            <id>release</id>
            <activation>
                <property>
                    <name>env.CI</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <author>false</author>
                            <doctitle>Liquibase ${project.name} ${project.version} API</doctitle>
                            <quiet>true</quiet>
                            <doclint>none</doclint>
                            <jarOutputDirectory>${project.basedir}/target</jarOutputDirectory>
                            <!-- reproducible builds: avoid timestamps in generated files -->
                            <notimestamp>true</notimestamp>
                        </configuration>
                        <executions>
                            <execution>
                                <id>jar-javadoc</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.coderplus.maven.plugins</groupId>
                        <artifactId>copy-rename-maven-plugin</artifactId>
                        <version>${copy-rename-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>copy</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <fileSets>
                                        <fileSet>
                                            <sourceFile>${project.basedir}/pom.xml</sourceFile>
                                            <destinationFile>${project.basedir}/target/${project.artifactId}-${project.version}.pom</destinationFile>
                                        </fileSet>
                                    </fileSets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>sign</id>
            <activation>
                <property>
                    <name>signWithMavenGPGPlugin</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- Profile to run integration tests against MySQL and MariaDB -->
            <id>run-its</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>download-percona-toolkit</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${project.basedir}/src/main/scripts/download-toolkit.sh</executable>
                                    <arguments>
                                        <argument>LATEST</argument>
                                        <argument>${percona.toolkit.version}</argument>
                                    </arguments>
                                    <environmentVariables>
                                        <USE_CACHE>${percona.toolkit.usecache}</USE_CACHE>
                                        <CACHE_DIR>${percona.toolkit.cachedir}</CACHE_DIR>
                                        <TARGET>${project.build.directory}/percona-toolkit</TARGET>
                                    </environmentVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <images>
                                <image>
                                    <name>${mysql_image}</name>
                                    <alias>liquibase-percona-mysql</alias>
                                    <run>
                                        <env>
                                            <MYSQL_ROOT_PASSWORD>${config_password}</MYSQL_ROOT_PASSWORD>
                                        </env>
                                        <cmd>
                                            <exec>
                                                <!-- set server_id to 1 for mysql 5.7 and percona-toolkit 3.5.5, see https://jira.percona.com/browse/PT-2268
                                                Note: mysql 8.0 and mariadb use by default server_id=1, only mysql 5.7 uses server_id=0 as default.
                                                -->
                                                <arg>--server-id=1</arg>
                                            </exec>
                                        </cmd>
                                        <containerNamePattern>%a</containerNamePattern>
                                        <network>
                                            <mode>bridge</mode>
                                        </network>
                                        <ports>
                                            <port>config_port:3306</port>
                                        </ports>
                                        <wait>
                                            <tcp>
                                                <ports>
                                                    <port>3306</port>
                                                </ports>
                                            </tcp>
                                            <time>180000</time>
                                        </wait>
                                    </run>
                                </image>
                                <image>
                                    <name>${mariadb_image}</name>
                                    <alias>liquibase-percona-mariadb</alias>
                                    <run>
                                        <env>
                                            <MYSQL_ROOT_PASSWORD>${config_password}</MYSQL_ROOT_PASSWORD>
                                        </env>
                                        <containerNamePattern>%a</containerNamePattern>
                                        <network>
                                            <mode>bridge</mode>
                                        </network>
                                        <ports>
                                            <port>config_port_mariadb:3306</port>
                                        </ports>
                                        <wait>
                                            <tcp>
                                                <ports>
                                                    <port>3306</port>
                                                </ports>
                                            </tcp>
                                            <time>180000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-docker</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-invoker-plugin</artifactId>
                        <configuration>
                            <!-- <debug>true</debug> --><!-- -Dinvoker.debug=true -->
                            <streamLogsOnFailures>true</streamLogsOnFailures>
                            <projectsDirectory>src/it</projectsDirectory>
                            <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                            <preBuildHookScript>${itPrebuildHookScript}</preBuildHookScript>
                            <postBuildHookScript>verify</postBuildHookScript>
                            <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                            <settingsFile>src/it/settings.xml</settingsFile>
                            <addTestClassPath>true</addTestClassPath>
                            <pomIncludes>
                                <pomInclude>*/pom.xml</pomInclude>
                            </pomIncludes>
                            <setupIncludes>
                                <setupInclude>sharedScripts/pom.xml</setupInclude>
                            </setupIncludes>
                            <goals>
                                <goal>pre-integration-test</goal>
                            </goals>
                            <scriptVariables>
                                <config_host>${config_host}</config_host>
                                <config_port>${config_port}</config_port>
                                <config_port_mariadb>${config_port_mariadb}</config_port_mariadb>
                                <config_user>${config_user}</config_user>
                                <config_password>${config_password}</config_password>
                                <config_dbname>${config_dbname}</config_dbname>
                                <mysql_image>${mysql_image}</mysql_image>
                                <mariadb_image>${mariadb_image}</mariadb_image>
                                <project_build_directory>${project.build.directory}</project_build_directory>
                                <prebuild_hook_script>${itPrebuildHookScript}</prebuild_hook_script>
                            </scriptVariables>
                            <environmentVariables>
                                <PATH>${project.build.directory}/percona-toolkit/percona-toolkit-${percona.toolkit.version}/bin:${env.PATH}</PATH>
                            </environmentVariables>
                        </configuration>
                        <executions>
                            <execution>
                                <id>integration-test</id>
                                <goals>
                                    <goal>install</goal>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>remote-repositories</id>
            <activation>
                <property>
                    <name>env.CI</name>
                    <value>true</value>
                </property>
            </activation>
            <repositories>
                <repository>
                    <id>liquibase</id>
                    <url>https://maven.pkg.github.com/liquibase/liquibase</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>liquibase-pro</id>
                    <url>https://maven.pkg.github.com/liquibase/liquibase-pro</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
</project>
