Conflicting groovy versions when running jetty

We have an application built with groovy 2.2.2 that works fine in itself, but when we run it with gradle 2.1 using jettyRun we get an exception since jettyRun has already loaded the incompatible groovy 2.3.6 version before the application is loaded:

Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.6 and you are trying to load version 2.2.2
 at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl$DefaultModuleListener.onModule( ~[groovy-all-2.2.2.jar:2.3.6]
 at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties( ~[groovy-all-2.2.2.jar:2.3.6]
 at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromMetaInf( ~[groovy-all-2.2.2.jar:2.3.6]
 at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModules( ~[groovy-all-2.2.2.jar:2.3.6]
 at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>( ~[groovy-all-2.2.2.jar:2.3.6]
 at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>( ~[groovy-all-2.2.2.jar:2.3.6]
 at groovy.lang.GroovySystem.<clinit>( ~[groovy-all-2.2.2.jar:2.3.6]

Is there any workaround for this that allows us to use gradle 2.1?

The bundled Jetty plugin is very outdated and limited. Among other things, it can’t run apps in a separate process. I recommend to use the third-party Gretty plugin instead (

OK thanks will try it.

I believe this should have worked to remove our own groovy version from the class path.

Unfortunately it had a disastrous side effect of somehow destroying the class path so that some parts of spring no longer would load. I suspect that realizing the dependencies by invoking the minus operator somehow did it too early. Strange.

[jettyRun,jettyRunWar]*.doFirst {
    httpPort = 8220
       // Must not have our own groovy
on the class path since it's already loaded by gradle
    // and if it isn't exactly the same version, then we get
    // "GroovyRuntimeException: Conflicting module versions"
    final FileCollection currentClasspath = classpath
    final FileCollection classpathWithoutGroovy = currentClasspath.filter {
        File f -> !'groovy-all')
    classpath = classpathWithoutGroovy

Turns out that the spring problems came from some esoteric change in how automatic string => class type conversion was handled in groovy 2.2.2 -> 2.3.6. The above code works fine.

It would save us all a lot of time if you put up a warning sign in the documentation and referred to gretty.