Extra properties inheritance problem

issue-acknowledged
gradle-3530

(Loic Rossignol) #1

For gradle 2.13 and earlier, when an extra properties is override in a project, all sub project get value from it’s parent. Since 2.14 the value is override only for the given project and all other project get value from root project.
Why the behaviour has changed?

Example :

settings.gradle:

include 'sub1'
include 'sub1:sub1p1'
include 'sub1:sub1p2'
include 'sub2'
include 'sub2:sub2p1'
include 'sub2:sub2p2'

build.gradle:

ext.testProp='root value'
configure(project(':sub1')){
    ext.testProp='sub1 value'
}

allprojects{
    println(name + ' : ' + testProp)
}

For 2.13 and earlier, the output is :

gradle-inheritance : root value
sub1 : sub1 value
sub2 : root value
sub1p1 : sub1 value
sub1p2 : sub1 value
sub2p1 : root value
sub2p2 : root value

Since 2.14 :

gradle-inheritance : root value
sub1 : sub1 value
sub2 : root value
sub1p1 : root value
sub1p2 : root value
sub2p1 : root value
sub2p2 : root value

To keep behaviour of 2.13 in 2.14, we must set explicitly value in sub projects.

build.gradle:

ext.testProp='root value'
configure(project(':sub1')){
    ext.testProp='sub1 value'
    subprojects{
        ext.testProp='sub1 value'
    }
}

allprojects{
    println(name + ' : ' + testProp)
}