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
,LiquibaseDbclHistoryMojo
,LiquibaseDropAll
,LiquibaseGenerateChangeLogMojo
,LiquibaseHistoryMojo
,LiquibaseListLocksMojo
,LiquibaseReleaseLocksMojo
,LiquibaseTag
,LiquibaseTagExistsMojo
public abstract class AbstractLiquibaseMojo extends org.apache.maven.plugin.AbstractMojo
A base class for providing LiquibaseLiquibase
functionality.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
changeExecListenerClass
Specifies the fully qualified class name of the custom ChangeExecListenerprotected String
changeExecListenerPropertiesFile
Specifies the property file for controlling the custom ChangeExecListenerprotected String
changelogCatalogName
Specifies the schema Liquibase will use to create your changelog tables.protected String
changelogSchemaName
Specifies the schema Liquibase will use to create your changelog table.protected boolean
clearCheckSums
A flag that forces checksums to be cleared from the DATABASECHANGELOG table.protected String
commandName
protected Boolean
databaseChangelogHistoryCaptureExtensions
If true, extensions are captured in the history tableprotected Boolean
databaseChangelogHistoryCaptureSql
If true, executed SQL is captured in the history tableprotected Boolean
databaseChangelogHistoryEnabled
This property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table DATABASECHANGELOGHISTORY.protected String
databaseChangeLogLockTableName
Specifies the table name to use for the DATABASECHANGELOGLOCK table.protected String
databaseChangeLogTableName
Specifies the table name to use for the DATABASECHANGELOG table.protected String
databaseClass
Specifies the database object class.protected Boolean
dbclHistoryCaptureExtensions
If true, extensions are captured in the history tableprotected Boolean
dbclHistoryCaptureSql
If true, executed SQL is captured in the history tableprotected Boolean
dbclHistoryEnabled
This property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table DATABASECHANGELOGHISTORY.protected String
defaultCatalogName
Specifies the default catalog name to use for the database connection.protected DefaultChangeExecListener
defaultChangeExecListener
protected String
defaultSchemaName
Specifies the default schema name to use for the database connection.protected String
driver
Specifies the driver class name to use for the database connection.protected boolean
emptyPassword
Deprecated.Use an empty or null value for the password instead.protected boolean
includeArtifact
Includes a Maven project artifact in the class loader which obtains the liquibase.properties and changelog files.protected boolean
includeTestOutputDirectory
Includes the Maven test output directory in the class loader which obtains the liquibase.properties and changelog files.protected String
logFormat
Sets the format of log output to console or log files.protected String
logging
Deprecated.Logging managed by mavenprotected String
logLevel
Determines the minimum log level liquibase uses when logging.protected org.apache.maven.plugin.MojoExecution
mojoExecution
protected boolean
outputDefaultCatalog
Specifies whether to ignore the catalog/database name.protected boolean
outputDefaultSchema
Specifies whether to ignore the schema name.protected String
outputFileEncoding
A flag which indicates you want to set the character encoding of the output file during the updateSQL phase.protected String
password
Specifies the database password for database connection.protected Boolean
preserveSchemaCase
Specifies whether to preserve the case of schemas and catalogsprotected org.apache.maven.project.MavenProject
project
The Maven project that plugin is running under.protected boolean
promptOnNonLocalDatabase
Deprecated.No longer promptsprotected String
propertyFile
Specifies the liquibase.properties you want to use to configure Liquibase.protected boolean
propertyFileWillOverride
A flag which indicates you want the liquibase.properties file to override any settings provided in the Maven plugin configuration.protected String
propertyProviderClass
Specifies the property provider which must be a java.util.Properties implementation.protected String
psqlArgs
Specifies additional psql args.protected Boolean
psqlKeepTemp
Specifies whether to keep generated psql files.protected String
psqlKeepTempName
Specifies the name of generated psql files.protected String
psqlKeepTempPath
Specifies where to keep generated psql files.protected String
psqlLogFile
Specifies where to output psql logs.protected String
psqlPath
Specifies your psql path.protected Integer
psqlTimeout
Specifies psql timeout.protected String
searchPath
Specifies the locations where Liquibase can find your changelog files.protected org.apache.maven.execution.MavenSession
session
protected boolean
showBanner
Show the liquibase banner in output.protected boolean
skip
Specifies whether to skip running Liquibase.protected String
skipOnFileExists
Skip plugin execution if the specified file exists.protected String
sqlcmdArgs
Specifies additional sqlcmd args.protected String
sqlcmdCatalogName
Specifies sqlcmd catalog name.protected Boolean
sqlcmdKeepTemp
Specifies whether to keep generated sqlcmd files.protected String
sqlcmdKeepTempName
Specifies the name of generated sqlcmd files.protected Boolean
sqlcmdKeepTempOverwrite
Specifies whether to overwrite generated sqlcmd files.protected String
sqlcmdKeepTempPath
Specifies where to keep generated sqlcmd files.protected String
sqlcmdLogFile
Specifies where to output sqlcmd logs.protected String
sqlcmdPath
Specifies your sqlcmd path.protected Integer
sqlcmdTimeout
Specifies sqlcmd timeout.protected String
sqlPlusArgs
Specifies additional sqlplus args.protected Boolean
sqlPlusKeepTemp
Specifies whether to keep generated sqlplus files.protected String
sqlPlusKeepTempName
Specifies the name of generated sqlplus files.protected Boolean
sqlPlusKeepTempOverwrite
Specifies whether to overwrite generated sqlplus files.protected String
sqlPlusKeepTempPath
Specifies where to keep generated sqlplus files.protected String
sqlPlusLogFile
Specifies where to output sqlplus logs.protected String
sqlPlusPath
Specifies your sqlplus path.protected Integer
sqlPlusTimeout
Specifies sqlplus timeout.protected Properties
systemProperties
Specifies a list of system properties you want to pass to the database.protected String
url
Specifies the database URL you want to use to execute Liquibase.protected String
username
Specifies the database username for database connection.protected boolean
verbose
Controls the amount of output detail when you call the plugin.protected org.apache.maven.artifact.manager.WagonManager
wagonManager
The Maven Wagon manager to use when obtaining server authentication details.
-
Constructor Summary
Constructors Constructor Description AbstractLiquibaseMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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)
protected void
configureChangeLogProperties()
void
configureFieldsAndValues()
protected Liquibase
createLiquibase(Database db)
boolean
databaseConnectionRequired()
Optionally, an implementation of this mojo can override this to indicate that a connection to the database is not required.void
execute()
protected ClassLoader
getClassLoaderIncludingProjectClasspath()
Returns an isolated classloader.protected Field
getField(Class clazz, String name)
protected String
getLicenseKey()
Get the specified license key.protected Liquibase
getLiquibase()
org.apache.maven.plugin.logging.Log
getLog()
protected ClassLoader
getMavenArtifactClassLoader()
protected OutputStream
getOutputStream(String outputFile)
Returns the OutputStream based on whether there is an outputFile provided.protected Writer
getOutputWriter(File outputFile)
protected ResourceAccessor
getResourceAccessor(ClassLoader cl)
protected boolean
isPromptOnNonLocalDatabase()
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
setupBindInfoPackage()
void
setUrl(String url)
void
setUsername(String username)
-
-
-
Field Detail
-
preserveSchemaCase
@PropertyElement protected Boolean preserveSchemaCase
Specifies whether to preserve the case of schemas and catalogs
-
driver
@PropertyElement protected String driver
Specifies the driver class name to use for the database connection.
-
url
@PropertyElement protected String url
Specifies the database URL you want to use to execute Liquibase.
-
wagonManager
protected org.apache.maven.artifact.manager.WagonManager wagonManager
The Maven Wagon manager to use when obtaining server authentication details.
-
username
@PropertyElement protected String username
Specifies the database username for database connection.
-
password
@PropertyElement protected String password
Specifies the database password for database connection.
-
emptyPassword
@PropertyElement 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 thepassword
setting.
-
outputDefaultSchema
@PropertyElement protected boolean outputDefaultSchema
Specifies whether to ignore the schema name.
-
outputDefaultCatalog
@PropertyElement protected boolean outputDefaultCatalog
Specifies whether to ignore the catalog/database name.
-
defaultCatalogName
@PropertyElement protected String defaultCatalogName
Specifies the default catalog name to use for the database connection.
-
defaultSchemaName
@PropertyElement protected String defaultSchemaName
Specifies the default schema name to use for the database connection.
-
databaseClass
@PropertyElement protected String databaseClass
Specifies the database object class.
-
propertyProviderClass
@PropertyElement protected String propertyProviderClass
Specifies the property provider which must be a java.util.Properties implementation.
-
promptOnNonLocalDatabase
@PropertyElement protected boolean promptOnNonLocalDatabase
Deprecated.No longer prompts(DEPRECATED) Controls whether users are prompted before executing changeSet to a non-local database.
-
includeArtifact
@PropertyElement protected boolean includeArtifact
Includes a Maven project artifact in the class loader which obtains the liquibase.properties and changelog files.
-
includeTestOutputDirectory
@PropertyElement protected boolean includeTestOutputDirectory
Includes the Maven test output directory in the class loader which obtains the liquibase.properties and changelog files.
-
verbose
@PropertyElement protected boolean verbose
Controls the amount of output detail when you call the plugin.
-
logging
@PropertyElement protected String 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:
- maven-logging for more information.
-
logLevel
@PropertyElement protected String 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
@PropertyElement protected String propertyFile
Specifies the liquibase.properties you want to use to configure Liquibase.
-
propertyFileWillOverride
@PropertyElement protected boolean 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
@PropertyElement protected boolean clearCheckSums
A flag that forces checksums to be cleared from the DATABASECHANGELOG table.
-
systemProperties
@PropertyElement protected Properties systemProperties
Specifies a list of system properties you want to pass to the database.
-
project
protected org.apache.maven.project.MavenProject project
The Maven project that plugin is running under.
-
session
protected org.apache.maven.execution.MavenSession session
-
mojoExecution
protected org.apache.maven.plugin.MojoExecution mojoExecution
-
skip
@PropertyElement protected boolean skip
Specifies whether to skip running Liquibase. The use of this parameter is NOT RECOMMENDED but can be used when needed.
-
skipOnFileExists
@PropertyElement protected String skipOnFileExists
Skip plugin execution if the specified file exists. The use of this parameter is NOT RECOMMENDED but can be used when needed.
-
outputFileEncoding
@PropertyElement protected String outputFileEncoding
A flag which indicates you want to set the character encoding of the output file during the updateSQL phase.
-
changelogCatalogName
@PropertyElement protected String changelogCatalogName
Specifies the schema Liquibase will use to create your changelog tables.
-
changelogSchemaName
@PropertyElement protected String changelogSchemaName
Specifies the schema Liquibase will use to create your changelog table.
-
databaseChangeLogTableName
@PropertyElement protected String databaseChangeLogTableName
Specifies the table name to use for the DATABASECHANGELOG table.
-
databaseChangeLogLockTableName
@PropertyElement protected String databaseChangeLogLockTableName
Specifies the table name to use for the DATABASECHANGELOGLOCK table.
-
showBanner
@PropertyElement protected boolean showBanner
Show the liquibase banner in output.
-
searchPath
@PropertyElement protected String searchPath
Specifies the locations where Liquibase can find your changelog files.
-
psqlPath
@PropertyElement protected String psqlPath
Specifies your psql path.
-
psqlKeepTemp
@PropertyElement protected Boolean psqlKeepTemp
Specifies whether to keep generated psql files.
-
psqlKeepTempName
@PropertyElement protected String psqlKeepTempName
Specifies the name of generated psql files.
-
psqlKeepTempPath
@PropertyElement protected String psqlKeepTempPath
Specifies where to keep generated psql files.
-
psqlArgs
@PropertyElement protected String psqlArgs
Specifies additional psql args.
-
psqlTimeout
@PropertyElement protected Integer psqlTimeout
Specifies psql timeout.
-
psqlLogFile
@PropertyElement protected String psqlLogFile
Specifies where to output psql logs.
-
sqlPlusPath
@PropertyElement protected String sqlPlusPath
Specifies your sqlplus path.
-
sqlPlusKeepTemp
@PropertyElement protected Boolean sqlPlusKeepTemp
Specifies whether to keep generated sqlplus files.
-
sqlPlusKeepTempName
@PropertyElement protected String sqlPlusKeepTempName
Specifies the name of generated sqlplus files.
-
sqlPlusKeepTempPath
@PropertyElement protected String sqlPlusKeepTempPath
Specifies where to keep generated sqlplus files.
-
sqlPlusKeepTempOverwrite
@PropertyElement protected Boolean sqlPlusKeepTempOverwrite
Specifies whether to overwrite generated sqlplus files.
-
sqlPlusArgs
@PropertyElement protected String sqlPlusArgs
Specifies additional sqlplus args.
-
sqlPlusTimeout
@PropertyElement protected Integer sqlPlusTimeout
Specifies sqlplus timeout.
-
sqlPlusLogFile
@PropertyElement protected String sqlPlusLogFile
Specifies where to output sqlplus logs.
-
sqlcmdPath
@PropertyElement protected String sqlcmdPath
Specifies your sqlcmd path.
-
sqlcmdKeepTemp
@PropertyElement protected Boolean sqlcmdKeepTemp
Specifies whether to keep generated sqlcmd files.
-
sqlcmdKeepTempName
@PropertyElement protected String sqlcmdKeepTempName
Specifies the name of generated sqlcmd files.
-
sqlcmdKeepTempPath
@PropertyElement protected String sqlcmdKeepTempPath
Specifies where to keep generated sqlcmd files.
-
sqlcmdKeepTempOverwrite
@PropertyElement protected Boolean sqlcmdKeepTempOverwrite
Specifies whether to overwrite generated sqlcmd files.
-
sqlcmdArgs
@PropertyElement protected String sqlcmdArgs
Specifies additional sqlcmd args.
-
sqlcmdTimeout
@PropertyElement protected Integer sqlcmdTimeout
Specifies sqlcmd timeout.
-
sqlcmdLogFile
@PropertyElement protected String sqlcmdLogFile
Specifies where to output sqlcmd logs.
-
sqlcmdCatalogName
@PropertyElement protected String sqlcmdCatalogName
Specifies sqlcmd catalog name.
-
changeExecListenerClass
@PropertyElement protected String changeExecListenerClass
Specifies the fully qualified class name of the custom ChangeExecListener
-
changeExecListenerPropertiesFile
@PropertyElement protected String changeExecListenerPropertiesFile
Specifies the property file for controlling the custom ChangeExecListener
-
logFormat
@PropertyElement protected String 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
@PropertyElement(key="liquibase.dbclHistory.enabled") protected Boolean 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 databaseChangelogHistoryEnabled
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.
-
dbclHistoryCaptureSql
@PropertyElement(key="liquibase.dbclHistory.captureSql") protected Boolean dbclHistoryCaptureSql
If true, executed SQL is captured in the history table
-
databaseChangelogHistoryCaptureSql
@PropertyElement(key="liquibase.databaseChangelogHistory.captureSql") protected Boolean databaseChangelogHistoryCaptureSql
If true, executed SQL is captured in the history table
-
dbclHistoryCaptureExtensions
@PropertyElement(key="liquibase.dbclHistory.captureExtensions") protected Boolean dbclHistoryCaptureExtensions
If true, extensions are captured in the history table
-
databaseChangelogHistoryCaptureExtensions
@PropertyElement(key="liquibase.databaseChangelogHistory.captureExtensions") protected Boolean databaseChangelogHistoryCaptureExtensions
If true, extensions are captured in the history table
-
commandName
protected String commandName
-
defaultChangeExecListener
protected DefaultChangeExecListener defaultChangeExecListener
-
-
Method Detail
-
getLicenseKey
protected String getLicenseKey()
Get the specified license key. This first checks liquibaseLicenseKey and if no key is found, then returns liquibaseProLicenseKey.
-
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
-
getField
protected Field getField(Class clazz, String name) throws NoSuchFieldException
- Throws:
NoSuchFieldException
-
getLiquibase
protected Liquibase getLiquibase()
-
setupBindInfoPackage
protected void setupBindInfoPackage()
-
performLiquibaseTask
protected abstract void performLiquibaseTask(Liquibase liquibase) throws LiquibaseException
- 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.MojoExecutionException
Returns 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.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.
-
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
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 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
protected OutputStream getOutputStream(String outputFile) throws 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:
LiquibaseException
- if we cannot create the provided outputFile
-
-