The documentation says:
Properties and methods declared in a project are inherited to all its subprojects. — 24.12
I’ve created a minimal repro of this not being true: gradle-sub-inherit-props.zip (2.0 KB)
Can someone please shed some light on what I’m doing wrong or is it really a bug in Gradle?
Project structure
root
:sub
:sub:p1
:sub:p2
gradle.properties
files
PROP_1=defined in root, not overridden anywhere
PROP_2=defined in root, overridden in :sub
PROP_3=defined in root, overridden in :sub and :sub:p*
PROP_4=defined in :sub, not overridden anywhere
PROP_5=defined in :sub, overridden in :sub:p*
Output
of executing gradle props
(some lines omitted for brevity):
Actual
In root project 'gradle-sub-inherit-props' (normal):
PROP_1=value from root
PROP_2=value from root
PROP_3=value from root
In project ':sub' (normal):
PROP_1=value from root
PROP_2=value from sub
PROP_3=value from sub
PROP_4=value from sub
PROP_5=value from sub
In project ':sub:p1' (normal):
PROP_1=value from root
PROP_2=value from root
PROP_3=value from p1
PROP_4=value from sub
PROP_5=value from p1
Expected
In root project 'gradle-sub-inherit-props' (normal):
PROP_1=value from root
PROP_2=value from root
PROP_3=value from root
In project ':sub' (normal):
PROP_1=value from root
PROP_2=value from sub
PROP_3=value from sub
PROP_4=value from sub
PROP_5=value from sub
In project ':sub:p1' (normal):
PROP_1=value from root
PROP_2=value from sub <------ difference
PROP_3=value from p1
PROP_4=value from sub
PROP_5=value from p1
I would expect the gradle.properties
files to be inherited an overridden in a natural way.
Why does it get the value from root project, skipping :sub
instead of inheriting the override from :sub
?
I found this in 2.6 and got the same behavior when tested on 2.10.