"Changes to container configuration DSL" now disallows references to other configurations

(Anne Stellingwerf) #1

The following snippet used to work in Gradle up to version 1.10, but does not in 1.11-rc-1

apply plugin: 'base'
  configurations {
 b { extendsFrom aCompile}
D:\dev\bugGradle1-11>gradlew buildA
  FAILURE: Build failed with an exception.
  * Where:
Build file 'D:\dev\bugGradle1-11\build.gradle' line: 5
  * What went wrong:
A problem occurred evaluating root project 'bugGradle1-11'.
> Could not find property 'aCompile' on configuration ':b'.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

This appears to be related to Release notes/Potential breaking changes/Changes to container configuration DSL


Where is ‘aCompile’ defined?

(Anne Stellingwerf) #3

It is defined as there’s a config ‘a’, and the base plugin add ‘aCompile’ for that, I suppose.


I now see what’s happening. Consider the following snippet:

configurations {
    b { extends x }

In v1.10, Gradle will search for a configuration named ‘x’, and will create it if it doesn’t exist. This is almost always an error in your build script; you’re assuming the existence of a configuration that isn’t present, and you’ll end up extending an empty configuration.

In v1.11, Gradle will not automatically create this configuration. If you want to maintain the equivalent code, you’ll need to declare the configuration explicitly. So for your example, use the equivalent:

configurations {
    b { extends aCompile }