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,LiquibaseDropAll,LiquibaseGenerateChangeLogMojo,LiquibaseHistoryMojo,LiquibaseListLocksMojo,LiquibaseReleaseLocksMojo,LiquibaseTag,LiquibaseTagExistsMojo
public abstract class AbstractLiquibaseMojo extends org.apache.maven.plugin.AbstractMojoA base class for providing LiquibaseLiquibasefunctionality.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringchangeExecListenerClassSpecifies the fully qualified class name of the custom ChangeExecListenerprotected StringchangeExecListenerPropertiesFileSpecifies the property file for controlling the custom ChangeExecListenerprotected StringchangelogCatalogNameSpecifies the schema Liquibase will use to create your changelog tables.protected StringchangelogSchemaNameSpecifies the schema Liquibase will use to create your changelog table.protected booleanclearCheckSumsA flag that forces checksums to be cleared from the DATABASECHANGELOG table.protected StringcommandNameprotected StringdatabaseChangeLogLockTableNameSpecifies the table name to use for the DATABASECHANGELOGLOCK table.protected StringdatabaseChangeLogTableNameSpecifies the table name to use for the DATABASECHANGELOG table.protected StringdatabaseClassSpecifies the database object class.protected StringdefaultCatalogNameSpecifies the default catalog name to use for the database connection.protected DefaultChangeExecListenerdefaultChangeExecListenerprotected StringdefaultSchemaNameSpecifies the default schema name to use for the database connection.protected StringdriverSpecifies the driver class name to use for the database connection.protected booleanemptyPasswordDeprecated.Use an empty or null value for the password instead.protected booleanincludeArtifactIncludes a Maven project artifact in the class loader which obtains the liquibase.properties and changelog files.protected booleanincludeTestOutputDirectoryIncludes the Maven test output directory in the class loader which obtains the liquibase.properties and changelog files.protected StringlogFormatSets the format of log output to console or log files.protected StringloggingDeprecated.Logging managed by mavenprotected booleanoutputDefaultCatalogSpecifies whether to ignore the catalog/database name.protected booleanoutputDefaultSchemaSpecifies whether to ignore the schema name.protected StringoutputFileEncodingA flag which indicates you want to set the character encoding of the output file during the updateSQL phase.protected StringpasswordSpecifies the database password for database connection.protected BooleanpreserveSchemaCaseSpecifies whether to preserve the case of schemas and catalogsprotected org.apache.maven.project.MavenProjectprojectThe Maven project that plugin is running under.protected booleanpromptOnNonLocalDatabaseDeprecated.No longer promptsprotected StringpropertyFileSpecifies the liquibase.properties you want to use to configure Liquibase.protected booleanpropertyFileWillOverrideA flag which indicates you want the liquibase.properties file to override any settings provided in the Maven plugin configuration.protected StringpropertyProviderClassSpecifies the property provider which must be a java.util.Properties implementation.protected StringpsqlArgsSpecifies additional psql args.protected BooleanpsqlKeepTempSpecifies whether to keep generated psql files.protected StringpsqlKeepTempNameSpecifies the name of generated psql files.protected StringpsqlKeepTempPathSpecifies where to keep generated psql files.protected StringpsqlLogFileSpecifies where to output psql logs.protected StringpsqlPathSpecifies your psql path.protected IntegerpsqlTimeoutSpecifies psql timeout.protected StringsearchPathSpecifies the locations where Liquibase can find your changelog files.protected booleanshowBannerShow the liquibase banner in output.protected booleanskipSpecifies whether to skip running Liquibase.protected StringskipOnFileExistsSkip plugin execution if the specified file exists.protected StringsqlcmdArgsSpecifies additional sqlcmd args.protected StringsqlcmdCatalogNameSpecifies sqlcmd catalog name.protected BooleansqlcmdKeepTempSpecifies whether to keep generated sqlcmd files.protected StringsqlcmdKeepTempNameSpecifies the name of generated sqlcmd files.protected BooleansqlcmdKeepTempOverwriteSpecifies whether to overwrite generated sqlcmd files.protected StringsqlcmdKeepTempPathSpecifies where to keep generated sqlcmd files.protected StringsqlcmdLogFileSpecifies where to output sqlcmd logs.protected StringsqlcmdPathSpecifies your sqlcmd path.protected IntegersqlcmdTimeoutSpecifies sqlcmd timeout.protected StringsqlPlusArgsSpecifies additional sqlplus args.protected BooleansqlPlusKeepTempSpecifies whether to keep generated sqlplus files.protected StringsqlPlusKeepTempNameSpecifies the name of generated sqlplus files.protected BooleansqlPlusKeepTempOverwriteSpecifies whether to overwrite generated sqlplus files.protected StringsqlPlusKeepTempPathSpecifies where to keep generated sqlplus files.protected StringsqlPlusLogFileSpecifies where to output sqlplus logs.protected StringsqlPlusPathSpecifies your sqlplus path.protected IntegersqlPlusTimeoutSpecifies sqlplus timeout.protected PropertiessystemPropertiesSpecifies a list of system properties you want to to pass to the database.protected StringurlSpecifies the database URL you want to use to execute Liquibase.protected StringusernameSpecifies the database username for database connection.protected booleanverboseControls the amount of output detail when you call the plugin.protected org.apache.maven.artifact.manager.WagonManagerwagonManagerThe 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 voidcheckRequiredParametersAreSpecified()Performs some validation after the properties file has been loaded checking that all properties required have been specified.protected voidcleanup(Database db)protected voidconfigureChangeLogProperties()voidconfigureFieldsAndValues()protected LiquibasecreateLiquibase(Database db)booleandatabaseConnectionRequired()Optionally, an implementation of this mojo can override this to indicate that a connection to the database is not required.voidexecute()protected ClassLoadergetClassLoaderIncludingProjectClasspath()Returns an isolated classloader.protected FieldgetField(Class clazz, String name)protected StringgetLicenseKey()Get the specified license key.protected LiquibasegetLiquibase()protected ClassLoadergetMavenArtifactClassLoader()protected OutputStreamgetOutputStream(String outputFile)Returns the OutputStream based on whether there is an outputFile provided.protected WritergetOutputWriter(File outputFile)protected ResourceAccessorgetResourceAccessor(ClassLoader cl)protected booleanisPromptOnNonLocalDatabase()Deprecated.no longer promptsprotected voidparsePropertiesFile(InputStream propertiesInputStream)Parses a properties file and sets the associated fields in the plugin.protected abstract voidperformLiquibaseTask(Liquibase liquibase)protected voidprintSettings(String indent)Prints the settings that have been set of defaulted for the plugin.protected voidsetupBindInfoPackage()
-
-
-
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 thepasswordsetting.
-
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.
-
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 to pass to the database.
-
project
protected org.apache.maven.project.MavenProject project
The Maven project that plugin is running under.
-
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.
-
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.MojoExecutionExceptionorg.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.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.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:
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
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.
-
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
-
-