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


(aadi4287) #1

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
  }
}

(aadi4287) #2

Thanks Peter. That did the trick!


(Peter Niederwieser) #3

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]’.