Closed tkruemmel closed 4 years ago
Your custom task is actually completely separate from the Liquibase Gradle plugin. Your task uses JavaExec
to run Liquibase as if you had run it from the command line. The best documentation to follow would be here: http://www.liquibase.org/documentation/command_line.html. If you want to keep your task the way it is, --diffExcludeObjects
should become excludeObjects=DATABASECHANGELOG
(if you're using the default table). This option is helpfully excluded from the official documentation...
There is another way that does use the plugin. You could have a liquibase
block in your build.gradle that looks like this:
liquibase {
activities {
main {
changeLogFile 'src/main/db/main.groovy'
url project.ext.mainUrl
username project.ext.mainUsername
password project.ext.mainPassword
}
diffMain {
changeLogFile 'src/main/resources/db.changelog/db.changelog-master.yaml'
referenceUrl 'hibernate:spring:demoLiquibaseGit.domain.entity?dialect=org.hibernate.dialect.MySQL5Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy'
username project.ext.mainUsername
password project.ext.mainPassword
url 'jdbc:mariadb://localhost:3306/db?useUnicode=yes&characterEncoding=UTF-8'
referenceDriver 'liquibase.ext.hibernate.database.connection.HibernateDriver'
excludeObjects 'DATABASECHANGELOG'
}
}
runList = project.ext.runList
}
You'd probably also want runList=main
in gradle.properties
so that by default it only runs normal Liquibase tasks. You could then run your diff with gradle diff -PrunList=diffMain
Two things to keep in mind:
url
or username
are a direct match to the comnand line arguments of Liquibase.main
and diffMain
but you can call them whatever you want, as long as you reference them correctly in the runList
.I hope this helps.
I wrote a custom gradle task, to use the diff command. I would like to exclude the tables where Liquibase stores its information from the "diff" command. Here is my code: `task diffFixedDBvsEntities(type: JavaExec) { group = "liquibase"
}`
And here is the error I am getting:
Unexpected error running Liquibase: Unknown option: 'diffExcludeObjects' liquibase.exception.CommandLineParsingException: Unknown option: 'diffExcludeObjects' at liquibase.integration.commandline.Main.parseOptionArgument(Main.java:818) at liquibase.integration.commandline.Main.parseOptions(Main.java:764) at liquibase.integration.commandline.Main.run(Main.java:177) at liquibase.integration.commandline.Main.main(Main.java:129)
I used the documentation for the maven task, because I thought this would be the way to go.