Closed jasperjanuar closed 1 year ago
liquibase.properties already acts this way. It has the fallback values for properties that are explicitly specified. But
The current way to specify more specific values is by adding an activity
to the liquibase
block. These values can be static (like the changelogFile usually is), or it can be a property like project.ext.jdbcPassword
for a password. With this mechanism, you can do powerful things like override the changelogFile with something like this:
def changeLogToUse = 'src/main/db/changelog.groovy'
if ( project.hasProperty("changelog") ) {
changeLogToUse = project.ext.changelog
}
liquibase {
activities {
main {
changelogFile changeLogToUse
}
}
}
Another way is to have a different activity for running diffChangeLog. This is what jHipster does. It generates a liquibase block like this:
project.ext.diffChangelogFile = "src/main/resources/config/liquibase/changelog/" + new Date().format("yyyyMMddHHmmss") + "_changelog.xml"
liquibase {
activities {
main {
// regular args
}
diffLog {
changelogFile project.ext.diffChangelogFile
// other args
}
}
}
Then you can run gradlew -PrunList=diffLog diffChangelog
and you'd get a new file each time you run it.
Finally, release 2.2.0 of the plugin, which will hopefully be released in the next day or two, has a new liquibaseExtraArgs
property that you can use to specify properties to pass to Liquibase. These can override or add to the arguments in the liquibase block
. In your example, you could run gradlew diffChangelog -PliquibaseExtraArgs="changelogFile=myChangeLog.groovy"
@stevesaliman this is exactly what I've been looking for! Thanks!
Version 2.2.0 of the plugin has now been released, so you can use the liquibaseExtraArgs property now. Happy gradling!
What I'm trying to achieve is I want to have the configuration in liquibase.properties to act as fallback values, and be able to override specific values for some of the gradle liquibase tasks:
Eg.
diffChangelog
should not append the changesets to my master changelog file but instead output them to a new file, therefore i want to overwrite thechangelogFile
value to something different.Is this possible