Can't change a configuration which is not in unresolved state


(Andres Almiray) #1

First off, I’m aware that this question has been asked a few times already however the answers do not fit my scenario :frowning:

The following plugin defines two configurations: compileOnly and testCompileOnly. The proceeds to add a few dependencies to them, as every Griffon project requires them by default

https://github.com/griffon/griffon/blob/development/subprojects/gradle-griffon-plugin/src/main/groovy/org/codehaus/griffon/gradle/GriffonPlugin.groovy

A brand new Griffon project gets initialized using a Lazybones template, which results in the following build file

https://github.com/griffon/griffon/blob/development/templates/griffon-standard-templates/templates/griffon-swing-groovy/build.gradle

As you can see, this build adds more dependencies to the custom configurations created by the plugin. Now for the odd part. If this build is run with Gradle 1.12 then everything works, but it fails with Gradle 2.0-rc-1 with the aforementioned problem.

So my question is, how can a plugin add a custom configuration with some default dependencies while at the same time allowing developers to define more dependencies on those configurations?

TIA Andres

Previous answers: http://forums.gradle.org/gradle/topics/_you_cant_change_a_configuration_which_is_not_in_unresolved_state_when_building_for_sonar http://forums.gradle.org/gradle/topics/_you_cant_change_a_configuration_which_is_not_in_unresolved_state_in_trivial_multi_project_build http://forums.gradle.org/gradle/topics/you_cant_change_a_configuration_which_is_not_in_unresolved_state


(Peter Niederwieser) #2

Chances are that ‘collection += element’ has to be changed to ‘collection += [element]’ somewhere due to an incompatible change wrt. ‘+=’ in Groovy.


(Andres Almiray) #3

Thank you Peter, this solves the problem though the reasoning behind the fix was not apparent to me. Must go back to re-learn Groovy :wink: