org.liquibase.maven.plugins
Class AbstractLiquibaseMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.liquibase.maven.plugins.AbstractLiquibaseMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
AbstractLiquibaseChangeLogMojo, LiquibaseClearChecksumsMojo, LiquibaseDropAll, LiquibaseGenerateChangeLogMojo, LiquibaseListLocksMojo, LiquibaseReleaseLocksMojo, LiquibaseTag

public abstract class AbstractLiquibaseMojo
extends org.apache.maven.plugin.AbstractMojo

A base class for providing Liquibase Liquibase functionality.

Author:
Peter Murray, Florent Biville Test dependency is used because when you run a goal outside the build phases you want to have the same dependencies that it would had if it was ran inside test phase

Field Summary
protected  String changelogCatalogName
          Schema against which Liquibase changelog tables will be created.
protected  String changelogSchemaName
          Schema against which Liquibase changelog tables will be created.
protected  boolean clearCheckSums
          Flag for forcing the checksums to be cleared from teh DatabaseChangeLog table.
protected  String databaseClass
          The class to use as the database object.
protected  String defaultCatalogName
          The default catalog name to use the for database connection.
protected  String defaultSchemaName
          The default schema name to use the for database connection.
protected  String driver
          The fully qualified name of the driver class to use to connect to the database.
protected  boolean emptyPassword
          Deprecated. Use an empty or null value for the password instead.
protected  boolean includeArtifact
          Allows for the maven project artifact to be included in the class loader for obtaining the Liquibase property and DatabaseChangeLog files.
protected  boolean includeTestOutputDirectory
          Allows for the maven test output directory to be included in the class loader for obtaining the Liquibase property and DatabaseChangeLog files.
protected  String logging
          Controls the level of logging from Liquibase when executing.
protected  boolean outputDefaultCatalog
          Whether to ignore the schema name.
protected  boolean outputDefaultSchema
          Whether to ignore the schema name.
protected  String outputFileEncoding
          Flag to set the character encoding of the output file produced by Liquibase during the updateSQL phase.
protected  String password
          The database password to use to connect to the specified database.
protected  org.apache.maven.project.MavenProject project
          The Maven project that plugin is running under.
protected  boolean promptOnNonLocalDatabase
          Controls the prompting of users as to whether or not they really want to run the changes on a database that is not local to the machine that the user is current executing the plugin on.
protected  String propertyFile
          The Liquibase properties file used to configure the Liquibase Liquibase.
protected  boolean propertyFileWillOverride
          Flag allowing for the Liquibase properties file to override any settings provided in the Maven plugin configuration.
protected  boolean skip
          Set this to 'true' to skip running liquibase.
protected  Properties systemProperties
          List of system properties to pass to the database.
protected  String url
          The Database URL to connect to for executing Liquibase.
protected  String username
          The database username to use to connect to the specified database.
protected  boolean verbose
          Controls the verbosity of the output from invoking the plugin.
protected  org.apache.maven.artifact.manager.WagonManager wagonManager
          The Maven Wagon manager to use when obtaining server authentication details.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractLiquibaseMojo()
           
 
Method Summary
protected  void checkRequiredParametersAreSpecified()
          Performs some validation after the properties file has been loaded checking that all properties required have been specified.
protected  void cleanup(Database db)
           
 void configureFieldsAndValues(ResourceAccessor fo)
           
protected  Liquibase createLiquibase(ResourceAccessor fo, Database db)
           
 void execute()
           
protected  ClassLoader getClassLoaderIncludingProjectClasspath()
          Returns an isolated classloader.
protected  ResourceAccessor getFileOpener(ClassLoader cl)
           
protected  Liquibase getLiquibase()
           
protected  ClassLoader getMavenArtifactClassLoader()
           
protected  Writer getOutputWriter(File outputFile)
           
protected  boolean isPromptOnNonLocalDatabase()
           
protected  void parsePropertiesFile(InputStream propertiesInputStream)
          Parses a properties file and sets the assocaited fields in the plugin.
protected abstract  void performLiquibaseTask(Liquibase liquibase)
           
protected  void printSettings(String indent)
          Prints the settings that have been set of defaulted for the plugin.
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driver

protected String driver
The fully qualified name of the driver class to use to connect to the database.


url

protected String url
The Database URL to connect to for executing Liquibase.


wagonManager

protected org.apache.maven.artifact.manager.WagonManager wagonManager
The Maven Wagon manager to use when obtaining server authentication details.


username

protected String username
The database username to use to connect to the specified database.


password

protected String password
The database password to use to connect to the specified database.


emptyPassword

protected boolean emptyPassword
Deprecated. Use an empty or null value for the password instead.
Use an empty string as the password for the database connection. This should not be used along side the password setting.


outputDefaultSchema

protected boolean outputDefaultSchema
Whether to ignore the schema name.


outputDefaultCatalog

protected boolean outputDefaultCatalog
Whether to ignore the schema name.


defaultCatalogName

protected String defaultCatalogName
The default catalog name to use the for database connection.


defaultSchemaName

protected String defaultSchemaName
The default schema name to use the for database connection.


databaseClass

protected String databaseClass
The class to use as the database object.


promptOnNonLocalDatabase

protected boolean promptOnNonLocalDatabase
Controls the prompting of users as to whether or not they really want to run the changes on a database that is not local to the machine that the user is current executing the plugin on.


includeArtifact

protected boolean includeArtifact
Allows for the maven project artifact to be included in the class loader for obtaining the Liquibase property and DatabaseChangeLog files.


includeTestOutputDirectory

protected boolean includeTestOutputDirectory
Allows for the maven test output directory to be included in the class loader for obtaining the Liquibase property and DatabaseChangeLog files.


verbose

protected boolean verbose
Controls the verbosity of the output from invoking the plugin.


logging

protected String logging
Controls the level of logging from Liquibase when executing. The value can be "debug", "info", "warning", "severe", or "off". The value is case insensitive.


propertyFile

protected String propertyFile
The Liquibase properties file used to configure the Liquibase Liquibase.


propertyFileWillOverride

protected boolean propertyFileWillOverride
Flag allowing for the Liquibase properties file to override any settings provided in the Maven plugin configuration. By default if a property is explicity specified it is not overridden if it also appears in the properties file.


clearCheckSums

protected boolean clearCheckSums
Flag for forcing the checksums to be cleared from teh DatabaseChangeLog table.


systemProperties

protected Properties systemProperties
List of system properties to pass to the database.


project

protected org.apache.maven.project.MavenProject project
The Maven project that plugin is running under.


skip

protected boolean skip
Set this to 'true' to skip running liquibase. Its use is NOT RECOMMENDED, but quite convenient on occasion.


outputFileEncoding

protected String outputFileEncoding
Flag to set the character encoding of the output file produced by Liquibase during the updateSQL phase.


changelogCatalogName

protected String changelogCatalogName
Schema against which Liquibase changelog tables will be created.


changelogSchemaName

protected String changelogSchemaName
Schema against which Liquibase changelog tables will be created.

Constructor Detail

AbstractLiquibaseMojo

public AbstractLiquibaseMojo()
Method Detail

getOutputWriter

protected Writer getOutputWriter(File outputFile)
                          throws IOException
Throws:
IOException

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException,
                    org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

getLiquibase

protected Liquibase getLiquibase()

performLiquibaseTask

protected abstract void performLiquibaseTask(Liquibase liquibase)
                                      throws LiquibaseException
Throws:
LiquibaseException

isPromptOnNonLocalDatabase

protected boolean isPromptOnNonLocalDatabase()

createLiquibase

protected Liquibase createLiquibase(ResourceAccessor fo,
                                    Database db)
                             throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

configureFieldsAndValues

public void configureFieldsAndValues(ResourceAccessor fo)
                              throws org.apache.maven.plugin.MojoExecutionException,
                                     org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

getMavenArtifactClassLoader

protected ClassLoader getMavenArtifactClassLoader()
                                           throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

getClassLoaderIncludingProjectClasspath

protected ClassLoader getClassLoaderIncludingProjectClasspath()
                                                       throws org.apache.maven.plugin.MojoExecutionException
Returns an isolated classloader.

Returns:
ClassLoader
Throws:
org.apache.maven.plugin.MojoExecutionException

getFileOpener

protected ResourceAccessor getFileOpener(ClassLoader cl)

checkRequiredParametersAreSpecified

protected void checkRequiredParametersAreSpecified()
                                            throws org.apache.maven.plugin.MojoFailureException
Performs some validation after the properties file has been loaded checking that all properties required have been specified.

Throws:
org.apache.maven.plugin.MojoFailureException - If any property that is required has not been specified.

printSettings

protected void printSettings(String indent)
Prints the settings that have been set of defaulted for the plugin. These will only be shown in verbose mode.

Parameters:
indent - The indent string to use when printing the settings.

cleanup

protected void cleanup(Database db)

parsePropertiesFile

protected void parsePropertiesFile(InputStream propertiesInputStream)
                            throws org.apache.maven.plugin.MojoExecutionException
Parses a properties file and sets the assocaited fields in the plugin.

Parameters:
propertiesInputStream - The input stream which is the Liquibase properties that needs to be parsed.
Throws:
org.apache.maven.plugin.MojoExecutionException - If there is a problem parsing the file.


Copyright © 2013 Liquibase.org. All Rights Reserved.