项目作者: Jurrie

项目描述 :
This is a Maven plugin that allows for easy tagging of Liquibase files.
高级语言: Java
项目地址: git://github.com/Jurrie/liquibase-db-release.git
创建时间: 2017-02-03T13:47:36Z
项目社区:https://github.com/Jurrie/liquibase-db-release

开源协议:

下载


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:

  1. <!-- Version 1.2.3 -->
  2. <include file="myApp/1.2.3.xml" relativeToChangelogFile="true"></include>
  3. <changeSet id="Tag 1.2.3" author="liquibase-db-release">
  4. <tagDatabase tag="1.2.3"></tagDatabase>
  5. </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:

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

MyApp\latest.xml looks like this:

  1. <databaseChangeLog>
  2. <changeSet id="Make a change to our database" author="John Doe">
  3. ...
  4. </changeSet>
  5. </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:

  1. <databaseChangeLog>
  2. <changeSet id="Tag our database with 1.0.0" author="John Doe">
  3. <tagDatabase tag="1.0.0"></tagDatabase>
  4. </changeSet>
  5. <!-- Version 1.2.3 -->
  6. <include file="myApp/1.2.3.xml" relativeToChangelogFile="true"></include>
  7. <changeSet id="Tag 1.2.3" author="liquibase-db-release">
  8. <tagDatabase tag="1.2.3"></tagDatabase>
  9. </changeSet>
  10. <include file="myApp\latest.xml" relativeToChangelogFile="true"></include>
  11. </databaseChangeLog>

MyApp\1.2.3.xml looks like this:

  1. <databaseChangeLog>
  2. <changeSet id="Make a change to our database" author="John Doe">
  3. ...
  4. </changeSet>
  5. </databaseChangeLog>

MyApp\latest.xml looks like this:

  1. <databaseChangeLog>
  2. </databaseChangeLog>

How to use this plugin

Pom.xml

Configure this plugin in your pom.xml as follows:

  1. <plugin>
  2. <groupId>org.jurr.liquibase</groupId>
  3. <artifactId>liquibase-db-release-maven-plugin</artifactId>
  4. <version>${liquibase-db-release.version}</version>
  5. <configuration>
  6. <masterFiles>
  7. <masterFile>liquibase/master.xml</masterFile>
  8. <masterFile>liquibase/master_alternative.xml</masterFile>
  9. </masterFiles>
  10. <skippedIncludeFiles>
  11. <skippedIncludeFile>liquibase/demo_content.xml</skippedIncludeFile>
  12. <skippedIncludeFile>liquibase/test_content.xml</skippedIncludeFile>
  13. </skippedIncludeFiles>
  14. </configuration>
  15. </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.