Conflicting module versions with groovy-all

(RickH) #1

PreS: If anyone is interested in poking at the code, you can grab it at

I’m having a very strange problem with the build of one of our Gradle plugins. This plugin has been building just fine up until 7:52 PM yesterday. The next build happened at 9:09 PM and was triggered by a change in one of the downstream git repos. This one failed with very little information:

* What went wrong:
Execution failed for task ':compileGroovy'.
> java.lang.ExceptionInInitializerError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

When I got in this morning, I ran the build from the Jenkins workspace directly and added --stacktrace and got this:

Caused by: java.lang.ExceptionInInitializerError
        at org.gradle.api.internal.classloading.GroovySystemLoaderFactory.forClassLoader(
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(
        at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(
        at org.gradle.messaging.remote.internal.hub.MessageHub$
        ... 2 more
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.4.4 and you are trying to load version 2.4.6
        ... 9 more

I can see why this might be happening: the downstream dependencies do indeed include groovy-all 2.4.6 as a dependency. This isn’t something that just changed though: we’ve had 2.4.6 in there for quite some time, even before we ever added this plugin to our build server.

Here are things that make this weirder: this build works in a lot of other places. It works on my dev machine. It doesn’t work on my dev server (which is a completely separate machine that mostly doesn’t support builds). Heck, it worked on our build server as late as 7:52 PM yesterday. And then… it didn’t.

I tried a few other things that I thought should work. I removed the localGroovy() dependency and added the 2.4.6 dependency in directly:

dependencies {
    compile gradleApi()
    compile "org.codehaus.groovy:groovy-all:2.4.6"

Same error there. I tried adding an exclusion on the gradleApi() call:

compile "org.codehaus.groovy:groovy-all:2.4.6"
compile gradleApi() {
    exclude group: "org.codehaus.groovy", module: "groovy-all"

That doesn’t work at all because gradleApi() apparently doesn’t accept the closure for the exclusions (“org.gradle.api.internal.MissingMethodException: Could not find method gradleApi() for arguments…”).

I was able to make the build work by adding:

configurations {
    all*.exclude group: 'org.codehaus.groovy', module: 'groovy-all'

It seems like I should be able to tell Gradle what version of Groovy to use, but it doesn’t appear to be possible. Any idea why this happened all of a sudden? As best I know we upgraded nothing on the server and I see no changes in any of the pom.xml or build.gradle files in the dependency hierarchy that would have changed any of this stuff.

Also, the messaging on this particular error is REALLY bad. It took me a good while to figure out what was going on. Since Gradle is maintaining the dependency map, it should be able to give some more information as to the conflicts and where the versions are coming from.