Customizing Groovy version in Gradle when using the idea plugin

I am using Gradle in an IntelliJ plugin project.

I was having conflicts related to Groovy versions used by certain dependencies (e.g., Spock). So I tried to explicitly set the Groovy version in my project and excluded Groovy from all the libraries that were using it. It did not work.

After lots of debugging, it turns out that even if I delete from my gradle script all the dependencies grabbing Groovy, the problem still appeared as long as I tried to declare an explicit Groovy dependency. Then it turns out that this only happens when the idea plugin is applied. I mean: if I delete everything related to the intellij plugin from my build script, I can set the Groovy dependency version as expected.

This is my Gradle script:


plugins {
id "org.jetbrains.intellij" version "0.2.17"

repositories {

apply plugin: 'idea'
apply plugin: 'java'

apply plugin: 'groovy'

intellij {
pluginName 'myplugin'
version '2017.2.1'
type = 'IC'
sameSinceUntilBuild = true


group 'org.jetbrains'
version '1.0.10'

allprojects {
sourceSets {
main {
java.srcDirs 'src/main/java', 'gen'
resources.srcDirs 'src/main/resources'
test {
groovy.srcDirs 'src/test/groovy'

dependencies {
//this causes the error
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.12'
/* testCompile(group: 'org.spockframework', name: 'spock-core', version: '1.1-groovy-2.4') {
exclude group: 'org.codehaus.groovy'


And this is the full output with the error at the end:

:compileGroovy NO-SOURCE
:compileTestJava NO-SOURCE
:compileTestGroovy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestGroovy'.
> 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.

* Get more help at

9 actionable tasks: 9 executed
Conflicting module versions. Module [groovy-all is loaded in version 2.4.12 and you are trying to load version 2.4.6
11:36:59 PM: Task execution finished 'build'.



Is there a way to use a specific Groovy version when using the idea plugin ?


I also tried by means of adding this to the end of my Gradle script:


configurations.all {
resolutionStrategy {
force 'org.codehaus.groovy:groovy-all:2.4.12'


But it did not work. IntelliJ keeps telling me that " Cannot resolve symbol 'resolutionStrategy' ". Is that block correct ?


Thanks for any help.




Comment actions Permalink

Did you figure this out?

Comment actions Permalink

I was running into this as well.  Luckilly I don't require a very specific version of Groovy, so my dependency block looks like with compile localGroovy() solving the problem for me


dependencies {
compile gradleApi()
compile localGroovy()
testCompile("org.spockframework:spock-core:1.0-groovy-2.4") {
exclude group:'org.codehaus.groovy'

Please sign in to leave a comment.