liquibase.integration.ant.ChangeLogSyncTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
package liquibase.integration.ant;
import liquibase.Liquibase;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import java.io.Writer;
public class ChangeLogSyncTask extends BaseLiquibaseTask {
@Override
public void execute() throws BuildException {
super.execute();
if (!shouldRun()) {
return;
}
Liquibase liquibase = null;
try {
liquibase = createLiquibase();
Writer writer = createOutputWriter();
if (writer == null) {
liquibase.changeLogSync(getContexts());
} else {
liquibase.changeLogSync(getContexts(), writer);
writer.flush();
writer.close();
}
} catch (Exception e) {
throw new BuildException(e);
} finally {
closeDatabase(liquibase);
}
}
}