Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // Version:   $Id: $
  // Copyright: Copyright(c) 2008 Trace Financial Limited
  package org.liquibase.maven.plugins;
  
  
A Maven Mojo for performing Database Diffs.

Author(s):
Peter Murray
Goal:
diff
 
 public class LiquibaseDatabaseDiff extends AbstractLiquibaseChangeLogMojo {

    
The fully qualified name of the driver class to use to connect to the reference database. If this is not specified, then the AbstractLiquibaseMojo.driver will be used instead.

Parameter:
expression="${liquibase.referenceDriver}"
 
     protected String referenceDriver;

    
The reference database URL to connect to for executing Liquibase. If performing a diff against a Hibernate config xml file, then use "hibernate:PATH_TO_CONFIG_XML" as the URL. The path to the hibernate configuration file can be relative to the test classpath for the Maven project.

Parameter:
expression="${liquibase.referenceUrl}"
 
     protected String referenceUrl;

    
The reference database username to use to connect to the specified database.

Parameter:
expression="${liquibase.referenceUsername}"
 
     protected String referenceUsername;

    
The reference database password to use to connect to the specified database. If this is null then an empty password will be used.

Parameter:
expression="${liquibase.referencePassword}"
 
     protected String referencePassword;

    
The reference database password to use to connect to the specified database. If this is null then an empty password will be used.

Parameter:
expression="${liquibase.referenceDefaultSchemaName}"
 
     protected String referenceDefaultSchemaName;

    
The server id in settings.xml to use when authenticating with.

Parameter:
expression="${liquibase.referenceServer}"
 
     private String referenceServer;


    
The diff change log file to output the differences to. If this is null then the differences will be output to the screen.

Parameter:
expression="${liquibase.diffChangeLogFile}"
 
     protected String diffChangeLogFile;
 
     @Override
     public void execute() throws MojoExecutionExceptionMojoFailureException {
         if (referenceInfo != null) {
              = referenceInfo.getUserName();
              = referenceInfo.getPassword();
         }
         
         super.execute();
     }
 
     @Override
     protected void performLiquibaseTask(Liquibase liquibasethrows LiquibaseException {
         ClassLoader cl = null;
         try {
             cl = getMavenArtifactClassLoader();
         }
         catch (MojoExecutionException e) {
            throw new LiquibaseException("Could not create the class loader, " + ee);
        }
        Database db = liquibase.getDatabase();
        Database referenceDatabase = CommandLineUtils.createDatabaseObject(clnull);
        getLog().info("Performing Diff on database " + db.toString());
        if ( != null) {
            try {
                CommandLineUtils.doDiffToChangeLog(referenceDatabasedb);
                getLog().info("Differences written to Change Log File, " + );
            }
            catch (IOException e) {
                throw new LiquibaseException(e);
            }
            catch (ParserConfigurationException e) {
                throw new LiquibaseException(e);
            }
        } else {
            CommandLineUtils.doDiff(referenceDatabasedb);
        }
    }
    @Override
    protected void printSettings(String indent) {
        super.printSettings(indent);
        getLog().info(indent + "referenceDriver: " + );
        getLog().info(indent + "referenceUrl: " + );
        getLog().info(indent + "referenceUsername: " + );
        getLog().info(indent + "referencePassword: " + );
        getLog().info(indent + "referenceDefaultSchema: " + );
        getLog().info(indent + "diffChangeLogFile: " + );
    }
    @Override
    protected void checkRequiredParametersAreSpecified() throws MojoFailureException {
        if ( == null) {
            throw new MojoFailureException("A reference database or hibernate configuration file "
                    + "must be provided to perform a diff.");
        }
        if ( == null) {
             = "";
        }
    }
    @Override
    protected boolean isPromptOnNonLocalDatabase() {
        return false;
  }
New to GrepCode? Check out our FAQ X