How to change Gradle download location

Viewed 60346

I am starting to learn gradle. However when I am building Spring with Gradle; it downloads the dependency jars to

C:\Users\UserName\.gradle

Is there any way I can specify Gradle to download the dependency jars to a specific location? Just like I can specify repository location in Maven.

System information: Windows 7 64bit Gradle version 1.0

7 Answers

On android studio just go to File > Settings > Build Execution, Deployment > Gradle > Service directory path choose directory what you want.

You can add following line to your gradle.properties:

systemProp.gradle.user.home=/tmp/changed-gradle

Steps:

  • Set the GRADLE_USER_HOME environment variable to new path
  • On android studio just go to File > Settings > Build Execution, Deployment > Gradle > Service directory path choose directory what you want.
  • Restart the PC (important step, no one mentioned this surprisingly)

If you want to run gradle tasks through IDE then: You can also set in intelliJ editor>File>settings:

IntelliJ editor

Then restart the IDE.

If you want to run gradle tasks through command line then you have to set GRADLE_USER_HOME in environment system variables. Then restart the pc as others also said.

Related