Closed andygoossens closed 3 years ago
I have a Gradle build that runs a custom Java/Groovy class from a custom dependency. So, if your class could run in a build task rather than in a changeset this should work.
Another thing that comes to mind is that you might be able to put HelloWorld.groovy
inside your project's buildSrc/src/main/groovy/foo
directory. Classes in buildSrc shoudl automatically be part of the classpsth.
As far as i see it you can use the older buildscript plugin syntax and include jars with custom tasks etc. in the buildscript classpath. Not sure if it's needed for the jdbc drivers though:
buildscript {
repositories {
flatDir {
dirs 'libs'
}
mavenCentral()
}
dependencies {
classpath (
// liquibase
[group: 'org.liquibase', name:'liquibase-core', version:'3.5.3'],
// gradle plugin
[group: 'org.liquibase', name:'liquibase-gradle-plugin', version:'1.2.4'],
// jdbc driver
[group: 'com.ibm.db2', name: 'db2jcc', version: '3.59.81'],
// our own extensions
[name: 'liquibase-extensions', version: '1.0-SNAPSHOT']
)
}
}
Ok i tested a bit, and the classpath of a activity works for jdbc drivers but not for extensions as the extensions will not find the liquibase classes. So it seems extensions need to be attached to the buildscript classpath while jdbc drivers and ears/wars can be given to the activity classpath.
Not sure what can be done about it.
Edit: maybe it's that i used a method that was not present in liquibase 5.3.1 as i developed my changes against the latest version 3.5.3, ill check this out the next days
Version 2.0.0 of the plugin adds liquibaseRuntime
dependencies for setting up the classpath that Liquibase will use when it runs. Does this help solve the issue? If the custom code is part of the project itself, you can add liquibaseRuntime sourceSets.main.output
as a dependency.
Closed due to inactivity. If this is still an issue with the latest versions of Liquibase and the plugin, we can always open a new issue.
I am wondering whether it is possible to run a Java/Groovy/... class from the same Gradle module. When I tried it, it was giving me a java.lang.ClassNotFoundException.
Example with a XML changeset:
I assume that the class isn't part of the classpath that the plugin uses. Putting the class in an external artifact and then adding a 'classpath' dependency on it becomes more complex than it should be. :-(