does not take value from 'ancestor'

Either I do not correctly understand what is the ‘ancestor’ projects in terms of Gradle or does not work according to spec of

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

version = 1.2.3(
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


println 'Evaluating settings' = 'test'

include 'child-l1'
include 'child-l1:child-l2'



println 'Evaluating root'

project.ext.extProp = 'extProp-ValueFromRoot'
project.metaClass.extProp1 = 'extProp-ValueFromRoot'


println 'Evaluating child-l1'

project.ext.extProp = 'extProp-ValueFromChildL1'
project.metaClass.extProp1 = 'extProp-ValueFromChildL1'


println 'Evaluating child-l2'

println 'version=' + project.version
println 'extProp=' +'extProp')
println 'extProp1=' +'extProp1')

println 'extProp(parent)=' +'extProp')

task none {} (1.5 KB)

I’ve got why it is working this way - it appears that values from root ‘’ are fed into project.ext of every sub-module before evaluation. This way - property will be available immediately in each project, but it will not be possible to redefine value in parent for child projects.

I guess it would be better to feed ‘’ only into ‘rootProject.ext’. Child projects should lookup value in parents and have ability to (optionally) redefine value for self and child projects.

I’ve tried to workaround the problem by moving ‘non-global’ properties from into root build.gradle. Apart from being non-natural to define build properties explicitly in build.gradle, it also just does not work reliably:

  • project.version is nor inherited to children and nor evaluated from ancestors - thus always undefined
  • with org.gradle.configureondemand=true intermediate parent project is not evaluated and therefore behavior is different:


  • configureondemand=true - output is extProp=extProp-ValueFromRoot
  • configureondemand=false - output is extProp=extProp-ValueFromChildL1

So … it seems there is no reliable workaround for that problem.

Regarding inheritance of project version into children - it may be not applicable to most of projects, but in my case each sub-tree of sub-modules has own version and I’d like to set it once in the sub-tree root for all its children.