Install
There are a few ways to set up Liquibase Linter, depending on how you're using Liquibase.
Maven
Using the liquibase-linter-maven-plugin
If you just want to lint your liquibase scripts during build, but are not already using the liquibase-maven-plugin, you probably want to use the maven plugin provided by Liquibase Linter:
- Add the
liquibase-linter-maven-pluginto your pom. - Add
lqlint.jsonto thesrc/test/resourcesdirectory of your project. This is the default location, but you can change it in the plugin configuration.
See this simple example maven project to help get you started.
<plugin>
<groupId>io.github.liquibase-linter</groupId>
<artifactId>liquibase-linter-maven-plugin</artifactId>
<version>0.15.1</version>
<configuration>
<changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
<!-- This is the default value for configurationFile -->
<configurationFile>src/test/resources/lqlint.json</configurationFile>
</configuration>
<executions>
<execution>
<id>lint-liquibase-scripts</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Using the liquibase-maven-plugin
If you're already using the liquibase-maven-plugin, you can add liquibase-parser-extension that will lint automatically your scripts when they're parsed by Liquibase, using the Extensions feature in Liquibase:
- Add
liquibase-parser-extensionas a dependency of the Liquibase Maven plugin: - Add
lqlint.jsonto the root of your project
See this simple example maven project to help get you started
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration>...</configuration>
<dependencies>
<dependency>
<groupId>io.github.liquibase-linter</groupId>
<artifactId>liquibase-parser-extension</artifactId>
<version>0.15.1</version>
</dependency>
</dependencies>
<executions>...</executions>
</plugin>
Gradle
- Add
liquibase-parser-extensionas a dependency of the Liquibase Gradle plugin: - Add
lqlint.jsonto thelqlintdirectory under the root of your project
See this simple example gradle project to help get you started
dependencies {
liquibaseRuntime 'org.liquibase:liquibase-core:4.29.2'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:4.0.0'
liquibaseRuntime 'org.hsqldb:hsqldb:2.5.0'
liquibaseRuntime 'io.github.liquibase-linter:liquibase-parser-extension:0.15.1'
liquibaseRuntime files('lqlint')
}
Command Line
- Start with the latest Liquibase release zip.
- Download the latest Liquibase Linter jar from maven central and download
the dependencies required by Liquibase Linter, then add them to
the
libdirectory. - Add your
lqlint.jsonconfiguration file to thelibdirectory.
Compatibility
It doesn't matter whether you use Liquibase scripts written in XML, JSON or YAML, they will be linted just the same.
Liquibase Linter has been tested with Liquibase versions 4.0 through to the latest version, so you can confidently use it with those. We'll be working to keep up with newer versions of Liquibase as they happen.
As for Java support, Liquibase Linter needs at least Java 8, but you should have no issues with higher versions, unless they are with Liquibase itself.