Building and Dependency Management
Relevant source files
The following files were used as context for generating this wiki page:
The liquibase-clickhouse project is managed using Apache Maven, which handles the lifecycle from compilation to distribution. It is designed as a Liquibase extension that bridges Liquibase core functionality with the ClickHouse database. The project supports both single-instance and cluster-replicated modes, with the latter requiring specific configuration parameters loaded at runtime.
Sources: pom.xml:13-17, README.md:1-10
Project Configuration and Build Lifecycle
The project is identified by the group ID io.arenadata and produces a JAR artifact named liquibase-clickhouse. It targets Java 11 for both source and target compatibility.
Sources: pom.xml:13-16, pom.xml:61-62
Build Profiles
The build system includes two primary profiles for managing distribution:
- public-release: Configured to deploy artifacts to the OSSRH (Sonatype) repository. It includes automated generation of source JARs, Javadocs, and GPG signing of artifacts.
- internal-release: Configured for Arenadata's internal Artifactory instance.
Sources: pom.xml:65-132
The following diagram illustrates the build and distribution flow based on the active profile:
Sources: pom.xml:61-132
Dependency Management
The project relies on several core dependencies to provide ClickHouse support and facilitate robust testing environments.
Core Dependencies
| Group ID | Artifact ID | Version | Scope | Description |
|---|---|---|---|---|
com.clickhouse | clickhouse-jdbc | 0.5.0 | compile | Official ClickHouse JDBC driver. |
org.liquibase | liquibase-core | 4.15.0 | provided | Core Liquibase library. |
org.yaml | snakeyaml | 2.0 | compile | YAML parsing for changelogs. |
com.typesafe | config | 1.4.2 | compile | Configuration library for HOCON files. |
Sources: pom.xml:135-155, pom.xml:44-50
Test Dependencies
The testing suite utilizes JUnit 5 and Testcontainers to spin up actual ClickHouse instances for integration testing.
- Testcontainers (ClickHouse): Version 1.17.3 is used to provide a
clickhouse/clickhouse-server:22.3.8.39container during test execution. - JUnit 5: Version 5.4.0 is the primary testing framework.
Sources: pom.xml:145-154, src/test/java/liquibase/ClickHouseTest.java:44-46
Configuration Loading Logic
The extension uses com.typesafe.config (HOCON) to load cluster-specific parameters. This logic is encapsulated in the ParamsLoader class, which searches for a liquibaseClickhouse.conf file.
Configuration Parameters
The system validates three mandatory properties for cluster mode:
- clusterName: The name of the ClickHouse cluster.
- tableZooKeeperPathPrefix: The ZK path for replicated tables.
- tableReplicaName: The replica identifier (e.g.,
{replica}).
Sources: src/main/java/liquibase/ext/clickhouse/params/ParamsLoader.java:43-44, src/test/resources/testLiquibaseClickhouse.conf:3-7
Logic Flow for Configuration
The ParamsLoader determines the execution mode (Single-Instance vs. Cluster) based on the presence and validity of the configuration file.
Summary
Building the project requires Maven and a Java 11 environment. Dependency management is centralized in the pom.xml, ensuring compatibility between the clickhouse-jdbc driver and liquibase-core. The extension's behavior at runtime is further managed through external HOCON configuration, allowing it to adapt to various ClickHouse architectures without code changes.
Sources: pom.xml:61-62, README.md:15-25