Reading from alternate GRADLE_USER_HOME not working

The build.gradle file:


The gradle properties file under /tmp/otherhome/me/.gradle/

my.fav.prop = ABC:DEF

The command line:

./gradlew --gradle-user-home /tmp/otherhome/me

The result:

Cannot get property 'my.fav.prop' on extra properties extension as it does not exist

Using Gradle 2.7. What’s wrong?

From Build Environment document properties is loaded from this order.

  • in project directory.
  • in gradle user home directory.
  • system properties.

So, in your case, you have to move your file from /tmp/otherhome/me/.gradle/ into /tmp/otherhome/me/.

And command line option --gradle-user-home requires =, so the command will be as follows.

./gradlew --gradle-user-home=/tmp/otherhome/me

Or alternatively, to be “consistent” with the default, try to use a “GRADLE_USER_HOME” value of “/tmp/otherhome/me/.gradle”, which would require just changing your command line, not moving the properties file.