Package org.liquibase.maven.plugins
Class AbstractLiquibaseMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.liquibase.maven.plugins.AbstractLiquibaseMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractLiquibaseChangeLogMojo,AbstractLiquibaseChecksMojo,AbstractLiquibaseFlowMojo,LiquibaseClearChecksumsMojo,LiquibaseConnectMojo,LiquibaseDbclHistoryMojo,LiquibaseDropAll,LiquibaseGenerateChangeLogMojo,LiquibaseHistoryMojo,LiquibaseListLocksMojo,LiquibaseReleaseLocksMojo,LiquibaseTag,LiquibaseTagExistsMojo
public abstract class AbstractLiquibaseMojo
extends org.apache.maven.plugin.AbstractMojo
A base class for providing Liquibase
Liquibase functionality.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringSpecifies the fully qualified class name of the custom ChangeExecListenerprotected StringSpecifies the property file for controlling the custom ChangeExecListenerprotected StringSpecifies the schema Liquibase will use to create your changelog tables.protected StringSpecifies the schema Liquibase will use to create your changelog table.protected booleanA flag that forces checksums to be cleared from the DATABASECHANGELOG table.protected Stringprotected BooleanIf true, extensions are captured in the history tableprotected BooleanIf true, executed SQL is captured in the history tableprotected BooleanThis property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table DATABASECHANGELOGHISTORY.protected StringSpecifies the table name to use for the DATABASECHANGELOGLOCK table.protected StringSpecifies the table name to use for the DATABASECHANGELOG table.protected StringSpecifies the database object class.protected BooleanIf true, extensions are captured in the history tableprotected BooleanIf true, executed SQL is captured in the history tableprotected BooleanThis property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table DATABASECHANGELOGHISTORY.protected StringSpecifies the default catalog name to use for the database connection.protected liquibase.changelog.visitor.DefaultChangeExecListenerprotected StringSpecifies the default schema name to use for the database connection.protected StringSpecifies the driver class name to use for the database connection.protected booleanDeprecated.Use an empty or null value for the password instead.protected booleanIncludes a Maven project artifact in the class loader which obtains the liquibase.properties and changelog files.protected booleanIncludes the Maven test output directory in the class loader which obtains the liquibase.properties and changelog files.protected StringSets the format of log output to console or log files.protected StringDeprecated.Logging managed by mavenprotected StringDetermines the minimum log level liquibase uses when logging.protected org.apache.maven.plugin.MojoExecutionprotected booleanSpecifies whether to ignore the catalog/database name.protected booleanSpecifies whether to ignore the schema name.protected StringA flag which indicates you want to set the character encoding of the output file during the updateSQL phase.protected StringSpecifies the database password for database connection.protected BooleanSpecifies whether to preserve the case of schemas and catalogsprotected org.apache.maven.project.MavenProjectThe Maven project that plugin is running under.protected booleanDeprecated.No longer promptsprotected StringSpecifies the liquibase.properties you want to use to configure Liquibase.protected booleanA flag which indicates you want the liquibase.properties file to override any settings provided in the Maven plugin configuration.protected StringSpecifies the property provider which must be a java.util.Properties implementation.protected StringSpecifies additional psql args.protected BooleanSpecifies whether to keep generated psql files.protected StringSpecifies the name of generated psql files.protected StringSpecifies where to keep generated psql files.protected StringSpecifies where to output psql logs.protected StringSpecifies your psql path.protected IntegerSpecifies psql timeout.protected StringSpecifies the locations where Liquibase can find your changelog files.protected org.apache.maven.execution.MavenSessionprotected booleanShow the liquibase banner in output.protected booleanSpecifies whether to skip running Liquibase.protected StringSkip plugin execution if the specified file exists.protected StringSpecifies additional sqlcmd args.protected StringSpecifies sqlcmd catalog name.protected BooleanSpecifies whether to keep generated sqlcmd files.protected StringSpecifies the name of generated sqlcmd files.protected BooleanSpecifies whether to overwrite generated sqlcmd files.protected StringSpecifies where to keep generated sqlcmd files.protected StringSpecifies where to output sqlcmd logs.protected StringSpecifies your sqlcmd path.protected IntegerSpecifies sqlcmd timeout.protected StringSpecifies additional sqlplus args.protected BooleanSpecifies whether to keep generated sqlplus files.protected StringSpecifies the name of generated sqlplus files.protected BooleanSpecifies whether to overwrite generated sqlplus files.protected StringSpecifies where to keep generated sqlplus files.protected StringSpecifies where to output sqlplus logs.protected StringSpecifies your sqlplus path.protected IntegerSpecifies sqlplus timeout.protected PropertiesSpecifies a list of system properties you want to pass to the database.protected StringSpecifies the database URL you want to use to execute Liquibase.protected StringSpecifies the database username for database connection.protected booleanControls the amount of output detail when you call the plugin.protected org.apache.maven.artifact.manager.WagonManagerThe Maven Wagon manager to use when obtaining server authentication details.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidPerforms some validation after the properties file has been loaded checking that all properties required have been specified.protected voidcleanup(liquibase.database.Database db) protected voidvoidprotected liquibase.LiquibasecreateLiquibase(liquibase.database.Database db) booleanOptionally, an implementation of this mojo can override this to indicate that a connection to the database is not required.voidexecute()protected ClassLoaderReturns an isolated classloader.protected Fieldprotected StringGet the specified license key.protected liquibase.Liquibaseorg.apache.maven.plugin.logging.LoggetLog()protected ClassLoaderprotected OutputStreamgetOutputStream(String outputFile) Returns the OutputStream based on whether there is an outputFile provided.protected WritergetOutputWriter(File outputFile) protected liquibase.resource.ResourceAccessorprotected booleanDeprecated.no longer promptsprotected voidparsePropertiesFile(InputStream propertiesInputStream) Parses a properties file and sets the associated fields in the plugin.protected abstract voidperformLiquibaseTask(liquibase.Liquibase liquibase) protected voidprintSettings(String indent) Prints the settings that have been set of defaulted for the plugin.voidsetPassword(String password) protected voidvoidvoidsetUsername(String username) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getPluginContext, setLog, setPluginContext
-
Field Details
-
preserveSchemaCase
Specifies whether to preserve the case of schemas and catalogs -
driver
Specifies the driver class name to use for the database connection. -
url
Specifies the database URL you want to use to execute Liquibase. -
wagonManager
protected org.apache.maven.artifact.manager.WagonManager wagonManagerThe Maven Wagon manager to use when obtaining server authentication details. -
username
Specifies the database username for database connection. -
password
Specifies the database password for database connection. -
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 thepasswordsetting. -
outputDefaultSchema
Specifies whether to ignore the schema name. -
outputDefaultCatalog
Specifies whether to ignore the catalog/database name. -
defaultCatalogName
Specifies the default catalog name to use for the database connection. -
defaultSchemaName
Specifies the default schema name to use for the database connection. -
databaseClass
Specifies the database object class. -
propertyProviderClass
Specifies the property provider which must be a java.util.Properties implementation. -
promptOnNonLocalDatabase
Deprecated.No longer prompts(DEPRECATED) Controls whether users are prompted before executing changeSet to a non-local database. -
includeArtifact
Includes a Maven project artifact in the class loader which obtains the liquibase.properties and changelog files. -
includeTestOutputDirectory
Includes the Maven test output directory in the class loader which obtains the liquibase.properties and changelog files. -
verbose
Controls the amount of output detail when you call the plugin. -
logging
Deprecated.Logging managed by mavenDeprecated and ignored configuration property. Logging is managed via the standard maven logging system either using the -e, -X or -q flags or the ${maven.home}/conf/logging/simplelogger.properties file.- See Also:
-
logLevel
Determines the minimum log level liquibase uses when logging.Supported values are:
- DEBUG
- INFO
- WARNING
- ERROR
NOTE: The final log level is the maximum of this value and the maven log level. Thus, it is not possible to decrease the effective log level with this option.
-
propertyFile
Specifies the liquibase.properties you want to use to configure Liquibase. -
propertyFileWillOverride
A flag which indicates you want the liquibase.properties file to override any settings provided in the Maven plugin configuration. By default, if a property is explicitly specified it is not overridden if it also appears in the properties file. -
clearCheckSums
A flag that forces checksums to be cleared from the DATABASECHANGELOG table. -
systemProperties
Specifies a list of system properties you want to pass to the database. -
project
protected org.apache.maven.project.MavenProject projectThe Maven project that plugin is running under. -
session
protected org.apache.maven.execution.MavenSession session -
mojoExecution
protected org.apache.maven.plugin.MojoExecution mojoExecution -
skip
Specifies whether to skip running Liquibase. The use of this parameter is NOT RECOMMENDED but can be used when needed. -
skipOnFileExists
Skip plugin execution if the specified file exists. The use of this parameter is NOT RECOMMENDED but can be used when needed. -
outputFileEncoding
A flag which indicates you want to set the character encoding of the output file during the updateSQL phase. -
changelogCatalogName
Specifies the schema Liquibase will use to create your changelog tables. -
changelogSchemaName
Specifies the schema Liquibase will use to create your changelog table. -
databaseChangeLogTableName
Specifies the table name to use for the DATABASECHANGELOG table. -
databaseChangeLogLockTableName
Specifies the table name to use for the DATABASECHANGELOGLOCK table. -
showBanner
Show the liquibase banner in output. -
searchPath
Specifies the locations where Liquibase can find your changelog files. -
psqlPath
Specifies your psql path. -
psqlKeepTemp
Specifies whether to keep generated psql files. -
psqlKeepTempName
Specifies the name of generated psql files. -
psqlKeepTempPath
Specifies where to keep generated psql files. -
psqlArgs
Specifies additional psql args. -
psqlTimeout
Specifies psql timeout. -
psqlLogFile
Specifies where to output psql logs. -
sqlPlusPath
Specifies your sqlplus path. -
sqlPlusKeepTemp
Specifies whether to keep generated sqlplus files. -
sqlPlusKeepTempName
Specifies the name of generated sqlplus files. -
sqlPlusKeepTempPath
Specifies where to keep generated sqlplus files. -
sqlPlusKeepTempOverwrite
Specifies whether to overwrite generated sqlplus files. -
sqlPlusArgs
Specifies additional sqlplus args. -
sqlPlusTimeout
Specifies sqlplus timeout. -
sqlPlusLogFile
Specifies where to output sqlplus logs. -
sqlcmdPath
Specifies your sqlcmd path. -
sqlcmdKeepTemp
Specifies whether to keep generated sqlcmd files. -
sqlcmdKeepTempName
Specifies the name of generated sqlcmd files. -
sqlcmdKeepTempPath
Specifies where to keep generated sqlcmd files. -
sqlcmdKeepTempOverwrite
Specifies whether to overwrite generated sqlcmd files. -
sqlcmdArgs
Specifies additional sqlcmd args. -
sqlcmdTimeout
Specifies sqlcmd timeout. -
sqlcmdLogFile
Specifies where to output sqlcmd logs. -
sqlcmdCatalogName
Specifies sqlcmd catalog name. -
changeExecListenerClass
Specifies the fully qualified class name of the custom ChangeExecListener -
changeExecListenerPropertiesFile
Specifies the property file for controlling the custom ChangeExecListener -
logFormat
Sets the format of log output to console or log files. Open Source users default to unstructured TXT logs to the console or output log files. Pro users have the option to set value as JSON or JSON_PRETTY to enable json-structured log files to the console or output log files. -
dbclHistoryEnabled
This property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table DATABASECHANGELOGHISTORY. This table includes records of rollback, dropalls, and repeated runOnChange type activity, which is not available in the standard DATABASECHANGELOG table. -
databaseChangelogHistoryEnabled
@PropertyElement(key="liquibase.databaseChangelogHistory.enabled") protected Boolean databaseChangelogHistoryEnabledThis property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table DATABASECHANGELOGHISTORY. This table includes records of rollback, dropalls, and repeated runOnChange type activity, which is not available in the standard DATABASECHANGELOG table. -
dbclHistoryCaptureSql
If true, executed SQL is captured in the history table -
databaseChangelogHistoryCaptureSql
@PropertyElement(key="liquibase.databaseChangelogHistory.captureSql") protected Boolean databaseChangelogHistoryCaptureSqlIf true, executed SQL is captured in the history table -
dbclHistoryCaptureExtensions
@PropertyElement(key="liquibase.dbclHistory.captureExtensions") protected Boolean dbclHistoryCaptureExtensionsIf true, extensions are captured in the history table -
databaseChangelogHistoryCaptureExtensions
@PropertyElement(key="liquibase.databaseChangelogHistory.captureExtensions") protected Boolean databaseChangelogHistoryCaptureExtensionsIf true, extensions are captured in the history table -
commandName
-
defaultChangeExecListener
protected liquibase.changelog.visitor.DefaultChangeExecListener defaultChangeExecListener
-
-
Constructor Details
-
AbstractLiquibaseMojo
public AbstractLiquibaseMojo()
-
-
Method Details
-
setUrl
- Throws:
Exception
-
setUsername
- Throws:
Exception
-
setPassword
- Throws:
Exception
-
getLicenseKey
Get the specified license key. This first checks liquibaseLicenseKey and if no key is found, then returns liquibaseProLicenseKey. -
getOutputWriter
- Throws:
IOException
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
getField
- Throws:
NoSuchFieldException
-
getLiquibase
protected liquibase.Liquibase getLiquibase() -
setupBindInfoPackage
protected void setupBindInfoPackage() -
performLiquibaseTask
protected abstract void performLiquibaseTask(liquibase.Liquibase liquibase) throws liquibase.exception.LiquibaseException - Throws:
liquibase.exception.LiquibaseException
-
isPromptOnNonLocalDatabase
protected boolean isPromptOnNonLocalDatabase()Deprecated.no longer prompts -
createLiquibase
protected liquibase.Liquibase createLiquibase(liquibase.database.Database db) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
configureFieldsAndValues
public void configureFieldsAndValues() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
configureChangeLogProperties
protected void configureChangeLogProperties() throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-
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.MojoExecutionExceptionReturns an isolated classloader.- Returns:
- ClassLoader
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getResourceAccessor
protected liquibase.resource.ResourceAccessor getResourceAccessor(ClassLoader cl) throws IOException, org.apache.maven.plugin.MojoFailureException - Throws:
IOExceptionorg.apache.maven.plugin.MojoFailureException
-
checkRequiredParametersAreSpecified
protected void checkRequiredParametersAreSpecified() throws org.apache.maven.plugin.MojoFailureExceptionPerforms 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.
-
databaseConnectionRequired
public boolean databaseConnectionRequired()Optionally, an implementation of this mojo can override this to indicate that a connection to the database is not required. -
printSettings
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(liquibase.database.Database db) -
parsePropertiesFile
protected void parsePropertiesFile(InputStream propertiesInputStream) throws org.apache.maven.plugin.MojoExecutionException Parses a properties file and sets the associated 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.
-
getLog
public org.apache.maven.plugin.logging.Log getLog()- Specified by:
getLogin interfaceorg.apache.maven.plugin.Mojo- Overrides:
getLogin classorg.apache.maven.plugin.AbstractMojo
-
getOutputStream
protected OutputStream getOutputStream(String outputFile) throws liquibase.exception.LiquibaseException Returns the OutputStream based on whether there is an outputFile provided. If no outputFile parameter is provided, defaults to System.out.- Parameters:
outputFile- the string outputFile- Returns:
- the OutputStream to use
- Throws:
liquibase.exception.LiquibaseException- if we cannot create the provided outputFile
-