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 String
Specifies the fully qualified class name of the custom ChangeExecListenerprotected String
Specifies the property file for controlling the custom ChangeExecListenerprotected String
Specifies the schema Liquibase will use to create your changelog tables.protected String
Specifies the schema Liquibase will use to create your changelog table.protected boolean
A flag that forces checksums to be cleared from the DATABASECHANGELOG table.protected String
protected Boolean
If true, extensions are captured in the history tableprotected Boolean
If true, executed SQL is captured in the history tableprotected Boolean
This property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table DATABASECHANGELOGHISTORY.protected String
Specifies the table name to use for the DATABASECHANGELOGLOCK table.protected String
Specifies the table name to use for the DATABASECHANGELOG table.protected String
Specifies the database object class.protected Boolean
If true, extensions are captured in the history tableprotected Boolean
If true, executed SQL is captured in the history tableprotected Boolean
This property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table DATABASECHANGELOGHISTORY.protected String
Specifies the default catalog name to use for the database connection.protected DefaultChangeExecListener
protected String
Specifies the default schema name to use for the database connection.protected String
Specifies the driver class name to use for the database connection.protected boolean
Deprecated.Use an empty or null value for the password instead.protected boolean
Includes a Maven project artifact in the class loader which obtains the liquibase.properties and changelog files.protected boolean
Includes the Maven test output directory in the class loader which obtains the liquibase.properties and changelog files.protected String
Sets the format of log output to console or log files.protected String
Deprecated.Logging managed by mavenprotected String
Determines the minimum log level liquibase uses when logging.protected org.apache.maven.plugin.MojoExecution
protected boolean
Specifies whether to ignore the catalog/database name.protected boolean
Specifies whether to ignore the schema name.protected String
A flag which indicates you want to set the character encoding of the output file during the updateSQL phase.protected String
Specifies the database password for database connection.protected Boolean
Specifies whether to preserve the case of schemas and catalogsprotected org.apache.maven.project.MavenProject
The Maven project that plugin is running under.protected boolean
Deprecated.No longer promptsprotected String
Specifies the liquibase.properties you want to use to configure Liquibase.protected boolean
A flag which indicates you want the liquibase.properties file to override any settings provided in the Maven plugin configuration.protected String
Specifies the property provider which must be a java.util.Properties implementation.protected String
Specifies additional psql args.protected Boolean
Specifies whether to keep generated psql files.protected String
Specifies the name of generated psql files.protected String
Specifies where to keep generated psql files.protected String
Specifies where to output psql logs.protected String
Specifies your psql path.protected Integer
Specifies psql timeout.protected String
Specifies the locations where Liquibase can find your changelog files.protected org.apache.maven.execution.MavenSession
protected boolean
Show the liquibase banner in output.protected boolean
Specifies whether to skip running Liquibase.protected String
Skip plugin execution if the specified file exists.protected String
Specifies additional sqlcmd args.protected String
Specifies sqlcmd catalog name.protected Boolean
Specifies whether to keep generated sqlcmd files.protected String
Specifies the name of generated sqlcmd files.protected Boolean
Specifies whether to overwrite generated sqlcmd files.protected String
Specifies where to keep generated sqlcmd files.protected String
Specifies where to output sqlcmd logs.protected String
Specifies your sqlcmd path.protected Integer
Specifies sqlcmd timeout.protected String
Specifies additional sqlplus args.protected Boolean
Specifies whether to keep generated sqlplus files.protected String
Specifies the name of generated sqlplus files.protected Boolean
Specifies whether to overwrite generated sqlplus files.protected String
Specifies where to keep generated sqlplus files.protected String
Specifies where to output sqlplus logs.protected String
Specifies your sqlplus path.protected Integer
Specifies sqlplus timeout.protected Boolean
When set to true, this global property prevents DBCL and DBCLH sql from being present in console and logs during *-sql commands, such as update-sql, rollback-sql, etc.protected Properties
Specifies a list of system properties you want to pass to the database.protected String
Specifies the database URL you want to use to execute Liquibase.protected String
Specifies the database username for database connection.protected boolean
Controls the amount of output detail when you call the plugin.protected org.apache.maven.artifact.manager.WagonManager
The 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 void
Performs some validation after the properties file has been loaded checking that all properties required have been specified.protected void
protected void
void
protected Liquibase
boolean
Optionally, an implementation of this mojo can override this to indicate that a connection to the database is not required.void
execute()
protected ClassLoader
Returns an isolated classloader.protected Field
protected String
Get the specified license key.protected Liquibase
org.apache.maven.plugin.logging.Log
getLog()
protected ClassLoader
protected OutputStream
getOutputStream
(String outputFile) Returns the OutputStream based on whether there is an outputFile provided.protected Writer
getOutputWriter
(File outputFile) protected ResourceAccessor
protected boolean
Deprecated.no longer promptsprotected void
parsePropertiesFile
(InputStream propertiesInputStream) Parses a properties file and sets the associated 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.void
setPassword
(String password) protected void
void
void
setUsername
(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 thepassword
setting. -
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 -
suppressLiquibaseSql
When set to true, this global property prevents DBCL and DBCLH sql from being present in console and logs during *-sql commands, such as update-sql, rollback-sql, etc. -
commandName
-
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.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
getField
- Throws:
NoSuchFieldException
-
getLiquibase
-
setupBindInfoPackage
protected void setupBindInfoPackage() -
performLiquibaseTask
- Throws:
LiquibaseException
-
isPromptOnNonLocalDatabase
protected boolean isPromptOnNonLocalDatabase()Deprecated.no longer prompts -
createLiquibase
protected Liquibase createLiquibase(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.MojoFailureException
org.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 ResourceAccessor getResourceAccessor(ClassLoader cl) throws IOException, org.apache.maven.plugin.MojoFailureException - Throws:
IOException
org.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
-
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:
getLog
in interfaceorg.apache.maven.plugin.Mojo
- Overrides:
getLog
in classorg.apache.maven.plugin.AbstractMojo
-
getOutputStream
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:
LiquibaseException
- if we cannot create the provided outputFile
-