Adding dependencies to extended configuration does not error if extending configuration has already been resolved


(tslatcher) #1

Consider this example:

configurations {
  runtime {
    extendsFrom compile
  }
}
  configurations.runtime.files.each {
  println it.name
}
  dependencies {
  runtime group:'org.gradle', name:'gradle-core', version:'1.0'
}

This does the correct thing, it will error, informing the user “You can’t change a configuration which is not in unresolved state!” However, if we change the last 3 lines to this:

dependencies {
  compile group:'org.gradle', name:'gradle-core', version:'1.0'
}

This doesn’t error. I argue this should, since this should attempt to implicitly change the runtime configuration which is not in an unresolved state. The lack of an error makes it very hard to track down bugs related to altering configurations in tasks to be used later on in the build, a very useful feature of gradles configuration model.


(Luke Daley) #2

I’ve raised this as GRADLE-2921. Thanks for the report.