Liquibase DB release Maven plugin

This is a Maven plugin that allows for easy tagging of Liquibase files.

License

License

Categories

Categories

Maven Build Tools Liquibase Data Databases
GroupId

GroupId

org.jurr.liquibase
ArtifactId

ArtifactId

liquibase-db-release-maven-plugin
Last Version

Last Version

1.3.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Liquibase DB release Maven plugin
This is a Maven plugin that allows for easy tagging of Liquibase files.
Project URL

Project URL

https://github.com/Jurrie/liquibase-db-release
Source Code Management

Source Code Management

https://github.com/Jurrie/liquibase-db-release/tree/master

Download liquibase-db-release-maven-plugin

How to add to project

<plugin>
    <groupId>org.jurr.liquibase</groupId>
    <artifactId>liquibase-db-release-maven-plugin</artifactId>
    <version>1.3.0</version>
</plugin>

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.2.3
org.codehaus.plexus : plexus-interactivity-api jar 1.0
org.codehaus.plexus : plexus-utils jar 3.3.0
org.apache.maven : maven-settings jar 3.2.3
com.google.code.findbugs : jsr305 jar 3.0.2

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.6.0

test (7)

Group / Artifact Type Version
junit : junit jar 4.13
org.hamcrest : hamcrest-core jar 1.3
org.xmlmatchers : xml-matchers jar 1.0-RC1
xml-apis : xml-apis jar 1.4.01
io.takari.maven.plugins : takari-plugin-testing jar 2.9.2
org.apache.maven : maven-core jar 3.2.3
org.apache.maven : maven-compat jar 3.2.3

Project Modules

There are no modules declared in this project.

liquibase-db-release-maven-plugin

This is a Maven plugin that is designed to help with tagging a Liquibase file.

What this plugin does

The plugin will:

  • Move all include files to a named variant;
  • Create empty latest include files;
  • Include a tagDatabase changeSet in the master files

The tagDatabase changeSet looks like:

<!-- Version 1.2.3 -->
<include file="myApp/1.2.3.xml" relativeToChangelogFile="true"></include>
<changeSet id="Tag 1.2.3" author="liquibase-db-release">
	<tagDatabase tag="1.2.3"></tagDatabase>
</changeSet>

The plugin in more detail

The plugin assumes that the Liquibase has one or more master files. When you create a database, these are the files you run with Liquibase. The master files are the files where this plugin will insert a tag into.

The plugin also assumes that the master files will include other files. These files are the files that will be versioned.

For example, take the following structure:

  • master.xml
  • myApp\latest.xml

Master.xml looks like this:

<databaseChangeLog>
	<changeSet id="Tag our database with 1.0.0" author="John Doe">
		<tagDatabase tag="1.0.0"></tagDatabase>
	</changeSet>
	<include file="myApp\latest.xml" relativeToChangelogFile="true"></include>
</databaseChangeLog>

MyApp\latest.xml looks like this:

<databaseChangeLog>
	<changeSet id="Make a change to our database" author="John Doe">
		...
	</changeSet>
</databaseChangeLog>

After running mvn liquibase-db-release:tag for version "1.2.3", we have the following structure:

  • master.xml
  • myApp\1.2.3.xml
  • myApp\latest.xml

Master.xml looks like this:

<databaseChangeLog>
	<changeSet id="Tag our database with 1.0.0" author="John Doe">
		<tagDatabase tag="1.0.0"></tagDatabase>
	</changeSet>

	<!-- Version 1.2.3 -->
	<include file="myApp/1.2.3.xml" relativeToChangelogFile="true"></include>
	<changeSet id="Tag 1.2.3" author="liquibase-db-release">
		<tagDatabase tag="1.2.3"></tagDatabase>
	</changeSet>

	<include file="myApp\latest.xml" relativeToChangelogFile="true"></include>
</databaseChangeLog>

MyApp\1.2.3.xml looks like this:

<databaseChangeLog>
	<changeSet id="Make a change to our database" author="John Doe">
		...
	</changeSet>
</databaseChangeLog>

MyApp\latest.xml looks like this:

<databaseChangeLog>
</databaseChangeLog>

How to use this plugin

Pom.xml

Configure this plugin in your pom.xml as follows:

<plugin>
	<groupId>org.jurr.liquibase</groupId>
	<artifactId>liquibase-db-release-maven-plugin</artifactId>
	<version>${liquibase-db-release.version}</version>
	<configuration>
		<masterFiles>
			<masterFile>liquibase/master.xml</masterFile>
			<masterFile>liquibase/master_alternative.xml</masterFile>
		</masterFiles>
		<skippedIncludeFiles>
			<skippedIncludeFile>liquibase/demo_content.xml</skippedIncludeFile>
			<skippedIncludeFile>liquibase/test_content.xml</skippedIncludeFile>
		</skippedIncludeFiles>
	</configuration>
</plugin>

Just run mvn liquibase-db-release:tag. The plugin will ask you for a new version. If you want to run this in batch mode, use mvn liquibase-db-release:tag -B -DnewVersion=1.2.3.

Versions

Version
1.3.0
1.2.0
1.1.0
1.0.0