~/.gradle/gradle.properties file not being read
A quick and dirty solution is just to simply put the gradle.properties right next to your build.gradle, that will guarantee it will be read. I realize this doesn't solve a single centralized source of common properties, but at least it's something.
By default, without setting GRADLE_USER_HOME
, it should work. I tested it in v3.5
.
But make sure if your are running it as the right user. For ex, if you do your ./gradlew build
using sudo
, then gradle.properties
in your home folder will not be picked up.
To make sure the default gradle user home, you can run gradle with the --debug
option and look out for the below line,
[DEBUG] [org.gradle.internal.buildevents.BuildLogger] Gradle user home:
The problem was that I made an assumption that wasn't true. If you look at section 14.2 of the gradle documentation, it says:
You can place a gradle.properties file in the Gradle user home directory (defined by the “GRADLE_USER_HOME” environment variable, which if not set defaults to USER_HOME/.gradle) or in your project directory.
My incorrect assumption was that USER_HOME just defaulted to the standard linux HOME environment variable. This is not true.
As soon as I export USER_HOME=$HOME
in my ~/.bashrc
everything works