Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referencing the user's home directory in a Gradle script

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")     } } ... 
like image 415
SeeNoWeevil Avatar asked Dec 07 '13 12:12

SeeNoWeevil


People also ask

Where is my Gradle user home directory?

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.

What is Gradle user home 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.

What is Gradle home location?

You should be able to find it in C:\Program Files\Android\Android Studio\Gradle\Gradle 2.2. 1 .


2 Answers

more generic (read: "groovy" & not using "ant")

def homePath = System.properties['user.home'] 
like image 199
roomsg Avatar answered Oct 05 '22 02:10

roomsg


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   } } 
like image 21
Shorn Avatar answered Oct 05 '22 03:10

Shorn