83

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

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
Ayusman
  • 8,509
  • 21
  • 79
  • 132

7 Answers7

111

You can set the GRADLE_USER_HOME environment variable, gradle.user.home system property, or --gradle-user-home command line parameter.

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • 4
    Using GRADLE_USER_HOME is not work for me(gradle still load wrapper in to the old folder).Please help me how to run --gradle-user-home command line parameter. – UmAnusorn Apr 05 '14 at 03:44
  • this might be helpful for people new to gradle. I also need to re run ./gradlew installDist in my project folder to re-download everything to the new GRADLE_USER_HOME – emily Jul 10 '15 at 20:39
  • 4
    Setting the gradle.user.home property in the gradle.properties does not change the location. – Eric Jul 25 '16 at 19:39
  • This doesn't change the location but the GRADLE_HOME variable finds mention in all newly created/imported projects. So whatever folder you mention inside that variable will have the 'scum in the name of gradle' downloaded there. So it won't clog up your C anymore. What a shithole of a open source IDE this is! – user30478 Aug 31 '18 at 18:45
9

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

4

You can also try to go in eclipse at window ->preferences -> gradle and change the directory there

GuessWhat
  • 71
  • 1
  • 7
4

You can add following line to your gradle.properties:

systemProp.gradle.user.home=/tmp/changed-gradle
musketyr
  • 808
  • 5
  • 16
4

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)
Nandan Wewhare
  • 445
  • 5
  • 11
0

If you are using gradle plugin in your eclipse and trying to import the gradle project than your gradle home is set to

C:\Users\UserName.gradle

In some cases your import build model will not work because of your user directory permission issue.

In this case you can copy your .gradle directory from below path

C:\Users\UserName\**.gradle**

paste into some directory where you have all permission and import the project.

In my case i moved my .gradle dir to z drive and than imported the project than made build model and it worked.

0

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.

a Learner
  • 4,944
  • 10
  • 53
  • 89