Ext property resolving differently in parent than in sub-modules

We are experiencing a problem where a property we have defined in build.grade in the project.ext section is resolving differently for the root of the project (parent project?) than it is in the sub-modules. We have defined a default value for this property (to be used in developer workspaces), but our ci server overrides this property on the command line (or via the USER_HOME/.gradle/gradle.properties)

I have the following build.gradle: project.ext {

personalProperty = ‘defaultValue’ }

allprojects {

task printProps << {

println “Project name = [${project.name}]”

println “The value of ext.personalProperty = [${personalProperty}]”

} }

I have the following settings.gradle: include ‘tmp-gradle-sub’

I have the following directory structure: ppp132-156:tmp-gradle bakerj$ ls -l total 24 -rw-r–r-- 1 bakerj staff 148 Nov 14 08:02 build.gradle -rw-r–r-- 1 bakerj staff

25 Nov 14 07:53 settings.gradle drwxr-xr-x 2 bakerj staff

68 Nov 14 07:52 tmp-gradle-sub (tmp-gradle-sub is empty)

When I run a build, and override personal property on the command line, you can see the variable resolves differently for the parent: ppp132-156:tmp-gradle bakerj$ gradle -q -PpersonalProperty=fromCommandLine printProps Project name = [tmp-gradle] The value of ext.personalProperty = [defaultValue] Project name = [tmp-gradle-sub] The value of ext.personalProperty = [fromCommandLine]

I also added a value for this property in my /user-home/.gradle/gradle.properties, and it exhibits the same problem: ppp132-156:tmp-gradle bakerj$ gradle -q printProps Project name = [tmp-gradle] The value of ext.personalProperty = [defaultValue] Project name = [tmp-gradle-sub] The value of ext.personalProperty = [fromPersonalGradleDotProperties ]

This seems like a bug to me. I would think that the variable should resolve the same both in the parent project and the sub-project.

My environment looks like this: vpn138-139:tmp-gradle bakerj$ gradle --version

------------------------------------------------------------ Gradle 1.8 ------------------------------------------------------------

Build time:

2013-09-24 07:32:33 UTC Build number: none Revision:

7970ec3503b4f5767ee1c1c69f8b4186c4763e3d

Groovy:

1.8.6 Ant:

Apache Ant™ version 1.9.2 compiled on July 8 2013 Ivy:

2.2.0 JVM:

1.7.0_45 (Oracle Corporation 24.45-b08) OS:

Mac OS X 10.8.5 x86_64

I believe that properties set via ‘-P’ or ‘gradle.properties’ are set for every project, and hence you’ll have to set the default for every project as well.