Just information: version of "groovy-all" in your build has to correspond to version used by Gradle

I was going to post this as a question, as I hit a problem with this, but perhaps just posting this as something to be aware of would be useful to some people.

One of my Gradle builds specifies a dependency on “groovy-all”, although I only do it to exclude a transitive dependency.

I had been working with version Gradle 2.3 for a while, and I had this dependency at version 2.3.9. I tried testing 2.4RC1, and I saw the following exception:

    groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.10 and you are trying to load version 2.3.9

It didn’t take me long to figure out that I needed to change the version in my dependency to 2.3.10 so this could work with Gradle 2.4.

I also verified that if I specify version 2.3.10, then Gradle 2.3 fails with a similar (but reversed) error message.

This is not a big deal, but is it possible in my build script to determine the version of Groovy in use? For now, my best fix for this is just writing a comment before the dependency describing the situation, but I’m curious to know if I could just dynamically figure out the version of Groovy that Gradle is using.

There’s localGroovy() for that

Yup, which works fine if you don’t need to add an exclusion. If you have
to add an exclusion, you can’t use it. Is it in the realm of possibilities
for that to take a closure so exclusions could be provided?

1 Like

IIRC, it’s just a file collection dependency so there’s not any metadata or a way to exclude things.

I assume you’re talking about your Yang plugin? https://github.com/davidmichaelkarr/GradleYangPlugin

I didn’t see a difference in the compile classpath with a groovy-all dependency (with exclude) or a localGroovy() dependency. I was checking with:

task checkCompileClasspath() << { sourceSets.main.compileClasspath.each { println "SAVE: " + it } }

I’ve read this reply numerous times, and I’m still not sure what point you’re trying to make.

I use the “org.codehaus.groovy:groovy-all:” dependency, as opposed to “localGroovy()” because I have to exclude commons-io from this, because Groovy uses commons-io 1.4, and I need version 2.4 (one of the auxiliary source files used by that plugin needs it).

1 Like