All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.liquibase.maven.plugins.LiquibaseUpdate Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package org.liquibase.maven.plugins;

import liquibase.*;
import liquibase.exception.LiquibaseException;
import org.liquibase.maven.property.PropertyElement;

/**
 * 

Applies the DatabaseChangeLogs to the database. Useful as part of the build * process.

* * @author Peter Murray * @description Liquibase Update Maven plugin * @goal update */ public class LiquibaseUpdate extends AbstractLiquibaseUpdateMojo { /** * Whether or not to perform a drop on the database before executing the change. * * @parameter property="liquibase.dropFirst" default-value="false" */ @PropertyElement protected boolean dropFirst; @Override protected void doUpdate(Liquibase liquibase) throws LiquibaseException { if (dropFirst) { liquibase.dropAll(); } try { Scope.child("rollbackOnError", rollbackOnError, () -> { if (changesToApply > 0) { liquibase.update(changesToApply, new Contexts(contexts), new LabelExpression(getLabelFilter())); } else { liquibase.update(toTag, new Contexts(contexts), new LabelExpression(getLabelFilter())); } }); } catch (Exception exception) { if (exception instanceof LiquibaseException) { handleUpdateException((LiquibaseException) exception); //need this until update-to-tag and update-count are refactored throw (LiquibaseException) exception; } else { throw new LiquibaseException(exception); } } } @Override protected void printSettings(String indent) { super.printSettings(indent); getLog().info(indent + "drop first? " + dropFirst); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy