Пример #1
0
 private void closeLiquibaseSilently(Liquibase liquibase) {
   if (liquibase != null) {
     try {
       liquibase.getDatabase().getConnection().close();
     } catch (DatabaseException ignored) {
     }
   }
 }
Пример #2
0
  @Override
  public void execute() throws BuildException {
    super.execute();

    Liquibase liquibase = null;
    try {
      PrintStream writer = createPrintStream();
      if (writer == null) {
        throw new BuildException("generateChangeLog requires outputFile to be set");
      }

      liquibase = createLiquibase();

      Database database = liquibase.getDatabase();
      DiffControl diffControl =
          new DiffControl(
              getDefaultCatalogName(), getDefaultSchemaName(), null, null, getDiffTypes());
      diffControl.setDataDir(getDataDir());

      DatabaseSnapshot referenceSnapshot =
          DatabaseSnapshotGeneratorFactory.getInstance()
              .createSnapshot(database, diffControl, DiffControl.DatabaseRole.REFERENCE);

      DiffResult diffResult =
          DiffGeneratorFactory.getInstance()
              .compare(referenceSnapshot, new DatabaseSnapshot(database), diffControl);
      //			diff.addStatusListener(new OutDiffStatusListener());

      if (getChangeLogFile() == null) {
        new DiffToChangeLog(diffResult).print(writer);
      } else {
        new DiffToChangeLog(diffResult).print(getChangeLogFile());
      }

      writer.flush();
      writer.close();
    } catch (Exception e) {
      throw new BuildException(e);
    } finally {
      closeDatabase(liquibase);
    }
  }