Gradle 2.0 idea plugin: adding a custom configuration to scope throws ClassCastException

Gradle 2.0 IDEA plugin: adding a custom configuration to scope throws ClassCastException:

java.io.File cannot be cast to org.gradle.api.artifacts.Configuration

This may be related to http://issues.gradle.org/browse/GRADLE-3101. However, as suggested in the workaround, I tried adding the idea module scope towards the end of the build script, and encountered the

exception: java.io.File cannot be cast to org.gradle.api.artifacts.Configuration

Confirmed that this works fine in Gradle 1.12

Here is the build script:

apply plugin: 'java'
apply plugin: 'idea'
  configurations {
  provided
  provided.extendsFrom(compile)
}
  dependencies {
    provided '...'
}
  idea {
  module {
    scopes.PROVIDED.plus += configurations.provided
  }
}

Thanks Peter. That did the trick!

When adding collections in Groovy 1.8.9 or later, the right-hand side must be a collection as well. Hence it’s ‘+= [configurations.provided]’.