Is there a cleaner way to reference a file in the user's home directory than doing the following in a gradle script? (referencing an Android keystore in this example)
homeDir = System.getenv('HOMEDRIVE') + System.getenv('HOMEPATH'); ... signingConfigs { release { storeFile file(homeDir + "\\.android\\releaseKeystore.jks") } } ...
The default Gradle user home directory is $USER_HOME/. gradle . A property defined in the properties file, in the Gradle user home directory, overrides the property values defined in a properties file in the project directory.
The Gradle user home directory ( $USER_HOME/.gradle by default) is used to store global configuration properties and initialization scripts as well as caches and log files.
You should be able to find it in C:\Program Files\Android\Android Studio\Gradle\Gradle 2.2. 1 .
more generic (read: "groovy" & not using "ant")
def homePath = System.properties['user.home']
Untested code, but how about something like this (might need parentheses around the "X as File" bit):
signingConfigs { release { storeFile "${System.properties['user.home']}${File.separator}.android${File.separator}releaseKeystore.jks" as File } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With