Package org.liquibase.maven.plugins

Source Code of org.liquibase.maven.plugins.LiquibaseUpdate

package org.liquibase.maven.plugins;

import liquibase.Contexts;
import liquibase.LabelExpression;
import liquibase.exception.LiquibaseException;
import liquibase.Liquibase;

/**
* 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 expression="${liquibase.dropFirst}" default-value="false"
     */
    protected boolean dropFirst;

  @Override
  protected void doUpdate(Liquibase liquibase) throws LiquibaseException {
      if (dropFirst) {
        liquibase.dropAll();
      }

    if (changesToApply > 0) {
      liquibase.update(changesToApply, new Contexts(contexts), new LabelExpression(labels));
    } else {
      liquibase.update(new Contexts(contexts), new LabelExpression(labels));
    }
  }

    @Override
    protected void printSettings(String indent) {
        super.printSettings(indent);
        getLog().info(indent + "drop first? " + dropFirst);

    }
}
TOP

Related Classes of org.liquibase.maven.plugins.LiquibaseUpdate

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.