Search in sources :

Example 1 with ChangeLogOutputFile

use of liquibase.integration.ant.type.ChangeLogOutputFile in project liquibase by liquibase.

the class DiffDatabaseToChangeLogTask method setOutputFile.

/**
     * @deprecated Use {@link #addConfiguredXml(ChangeLogOutputFile)} instead.
     * @param outputFile The file to write the change log to.
     */
@Deprecated
public void setOutputFile(FileResource outputFile) {
    log("The outputFile attribute is deprecated. Use a nested <xml>, <json>, <yaml>, or <txt> element instead.", Project.MSG_WARN);
    ChangeLogOutputFile changeLogOutputFile = new ChangeLogOutputFile();
    changeLogOutputFile.setOutputFile(outputFile);
    addConfiguredXml(changeLogOutputFile);
}
Also used : ChangeLogOutputFile(liquibase.integration.ant.type.ChangeLogOutputFile)

Example 2 with ChangeLogOutputFile

use of liquibase.integration.ant.type.ChangeLogOutputFile in project liquibase by liquibase.

the class DiffDatabaseToChangeLogTask method executeWithLiquibaseClassloader.

@Override
protected void executeWithLiquibaseClassloader() throws BuildException {
    for (ChangeLogOutputFile changeLogOutputFile : changeLogOutputFiles) {
        PrintStream printStream = null;
        String encoding = getOutputEncoding(changeLogOutputFile);
        try {
            FileResource outputFile = changeLogOutputFile.getOutputFile();
            ChangeLogSerializer changeLogSerializer = changeLogOutputFile.getChangeLogSerializer();
            printStream = new PrintStream(outputFile.getOutputStream(), true, encoding);
            DiffResult diffResult = getDiffResult();
            DiffOutputControl diffOutputControl = getDiffOutputControl();
            DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diffResult, diffOutputControl);
            diffToChangeLog.print(printStream, changeLogSerializer);
        } catch (UnsupportedEncodingException e) {
            throw new BuildException("Unable to diff databases to change log file. Encoding [" + encoding + "] is not supported.", e);
        } catch (IOException e) {
            throw new BuildException("Unable to diff databases to change log file. Error creating output stream.", e);
        } catch (ParserConfigurationException e) {
            throw new BuildException("Unable to diff databases to change log file. Error configuring parser.", e);
        } catch (DatabaseException e) {
            throw new BuildException("Unable to diff databases to change log file. " + e.toString(), e);
        } finally {
            FileUtils.close(printStream);
        }
    }
}
Also used : PrintStream(java.io.PrintStream) FileResource(org.apache.tools.ant.types.resources.FileResource) DiffOutputControl(liquibase.diff.output.DiffOutputControl) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ChangeLogSerializer(liquibase.serializer.ChangeLogSerializer) JsonChangeLogSerializer(liquibase.serializer.core.json.JsonChangeLogSerializer) YamlChangeLogSerializer(liquibase.serializer.core.yaml.YamlChangeLogSerializer) StringChangeLogSerializer(liquibase.serializer.core.string.StringChangeLogSerializer) XMLChangeLogSerializer(liquibase.serializer.core.xml.XMLChangeLogSerializer) IOException(java.io.IOException) ChangeLogOutputFile(liquibase.integration.ant.type.ChangeLogOutputFile) DiffToChangeLog(liquibase.diff.output.changelog.DiffToChangeLog) DiffResult(liquibase.diff.DiffResult) BuildException(org.apache.tools.ant.BuildException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DatabaseException(liquibase.exception.DatabaseException)

Example 3 with ChangeLogOutputFile

use of liquibase.integration.ant.type.ChangeLogOutputFile in project liquibase by liquibase.

the class GenerateChangeLogTask method setOutputFile.

/**
     * @deprecated Use {@link #addConfiguredXml(ChangeLogOutputFile)} instead.
     */
@Deprecated
public void setOutputFile(FileResource outputFile) {
    log("The outputFile attribute is deprecated. Use a nested <xml>, <json>, <yaml>, or <txt> element instead.", Project.MSG_WARN);
    ChangeLogOutputFile changeLogOutputFile = new ChangeLogOutputFile();
    changeLogOutputFile.setOutputFile(outputFile);
    addConfiguredXml(changeLogOutputFile);
}
Also used : ChangeLogOutputFile(liquibase.integration.ant.type.ChangeLogOutputFile)

Example 4 with ChangeLogOutputFile

use of liquibase.integration.ant.type.ChangeLogOutputFile in project liquibase by liquibase.

the class GenerateChangeLogTask method executeWithLiquibaseClassloader.

@Override
public void executeWithLiquibaseClassloader() throws BuildException {
    Liquibase liquibase = getLiquibase();
    Database database = liquibase.getDatabase();
    CatalogAndSchema catalogAndSchema = buildCatalogAndSchema(database);
    DiffOutputControl diffOutputControl = getDiffOutputControl();
    DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diffOutputControl);
    for (ChangeLogOutputFile changeLogOutputFile : changeLogOutputFiles) {
        String encoding = getOutputEncoding(changeLogOutputFile);
        PrintStream printStream = null;
        try {
            FileResource outputFile = changeLogOutputFile.getOutputFile();
            ChangeLogSerializer changeLogSerializer = changeLogOutputFile.getChangeLogSerializer();
            log("Writing change log file " + outputFile.toString(), Project.MSG_INFO);
            printStream = new PrintStream(outputFile.getOutputStream(), true, encoding);
            liquibase.generateChangeLog(catalogAndSchema, diffToChangeLog, printStream, changeLogSerializer);
        } catch (UnsupportedEncodingException e) {
            throw new BuildException("Unable to generate a change log. Encoding [" + encoding + "] is not supported.", e);
        } catch (IOException e) {
            throw new BuildException("Unable to generate a change log. Error creating output stream.", e);
        } catch (ParserConfigurationException e) {
            throw new BuildException("Unable to generate a change log. Error configuring parser.", e);
        } catch (DatabaseException e) {
            throw new BuildException("Unable to generate a change log. " + e.toString(), e);
        } finally {
            FileUtils.close(printStream);
        }
    }
}
Also used : PrintStream(java.io.PrintStream) FileResource(org.apache.tools.ant.types.resources.FileResource) DiffOutputControl(liquibase.diff.output.DiffOutputControl) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JsonChangeLogSerializer(liquibase.serializer.core.json.JsonChangeLogSerializer) StringChangeLogSerializer(liquibase.serializer.core.string.StringChangeLogSerializer) ChangeLogSerializer(liquibase.serializer.ChangeLogSerializer) YamlChangeLogSerializer(liquibase.serializer.core.yaml.YamlChangeLogSerializer) XMLChangeLogSerializer(liquibase.serializer.core.xml.XMLChangeLogSerializer) IOException(java.io.IOException) CatalogAndSchema(liquibase.CatalogAndSchema) ChangeLogOutputFile(liquibase.integration.ant.type.ChangeLogOutputFile) Liquibase(liquibase.Liquibase) Database(liquibase.database.Database) DiffToChangeLog(liquibase.diff.output.changelog.DiffToChangeLog) BuildException(org.apache.tools.ant.BuildException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DatabaseException(liquibase.exception.DatabaseException)

Aggregations

ChangeLogOutputFile (liquibase.integration.ant.type.ChangeLogOutputFile)4 IOException (java.io.IOException)2 PrintStream (java.io.PrintStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 DiffOutputControl (liquibase.diff.output.DiffOutputControl)2 DiffToChangeLog (liquibase.diff.output.changelog.DiffToChangeLog)2 DatabaseException (liquibase.exception.DatabaseException)2 ChangeLogSerializer (liquibase.serializer.ChangeLogSerializer)2 JsonChangeLogSerializer (liquibase.serializer.core.json.JsonChangeLogSerializer)2 StringChangeLogSerializer (liquibase.serializer.core.string.StringChangeLogSerializer)2 XMLChangeLogSerializer (liquibase.serializer.core.xml.XMLChangeLogSerializer)2 YamlChangeLogSerializer (liquibase.serializer.core.yaml.YamlChangeLogSerializer)2 BuildException (org.apache.tools.ant.BuildException)2 FileResource (org.apache.tools.ant.types.resources.FileResource)2 CatalogAndSchema (liquibase.CatalogAndSchema)1 Liquibase (liquibase.Liquibase)1 Database (liquibase.database.Database)1 DiffResult (liquibase.diff.DiffResult)1