1 package liquibase.integration.ant; 2 3 import liquibase.Liquibase; 4 import org.apache.tools.ant.AntClassLoader; 5 import org.apache.tools.ant.BuildException; 6 7 import java.io.Writer; 8 9 public class ChangeLogSyncTask extends BaseLiquibaseTask { 10 11 @Override 12 public void execute() throws BuildException { 13 super.execute(); 14 15 if (!shouldRun()) { 16 return; 17 } 18 19 Liquibase liquibase = null; 20 try { 21 liquibase = createLiquibase(); 22 23 Writer writer = createOutputWriter(); 24 if (writer == null) { 25 liquibase.changeLogSync(getContexts()); 26 } else { 27 liquibase.changeLogSync(getContexts(), writer); 28 writer.flush(); 29 writer.close(); 30 } 31 32 } catch (Exception e) { 33 throw new BuildException(e); 34 } finally { 35 closeDatabase(liquibase); 36 } 37 } 38 }