Either I do not correctly understand what is the ‘ancestor’ projects in terms of Gradle or project.property(name)
does not work according to spec of project.property(name):
6 . Search up through this project’s ancestor projects for a convention property or extra property with the given name.
In the test project (child-l1:child-l2
) below I expect this to be printed (because values are redefined in the immediate parent project child-l1
):
version = '1.2.3(child-l1)'
extProp = 'extProp-ValueFromChildL1'
extProp1 = 'extProp-ValueFromChildL1'
but I’m getting following (values are taken from root gradle.properties
)
version = 1.2.3(gradle.properties)
extProp = extProp-ValueFromGradleProperties
extProp1 = extProp1-ValueFromGradleProperties
Test project is attached and its files are provided below. For the test, i’m running
gradle none
in the folder ./child-l1/child-l2
. Gradle version is 1.10
settings.gradle
println 'Evaluating settings'
rootProject.name = 'test'
include 'child-l1'
include 'child-l1:child-l2'
gradle.properties
#org.gradle.configureondemand=false
version=1.2.3(gradle.properties)
extProp=extProp-ValueFromGradleProperties
extProp1=extProp1-ValueFromGradleProperties
build.gradle
println 'Evaluating root'
project.version='1.2.3(root)'
project.ext.extProp = 'extProp-ValueFromRoot'
project.metaClass.extProp1 = 'extProp-ValueFromRoot'
./child-l1/build.gradle
println 'Evaluating child-l1'
project.version='1.2.3(child-l1)'
project.ext.extProp = 'extProp-ValueFromChildL1'
project.metaClass.extProp1 = 'extProp-ValueFromChildL1'
./child-l1/child-l2/build.gradle
println 'Evaluating child-l2'
println 'version=' + project.version
println 'extProp=' + project.property('extProp')
println 'extProp1=' + project.property('extProp1')
println 'extProp(parent)=' + project.parent.property('extProp')
task none {}
test-project.zip (1.5 KB)