6

I'm looking for a way to refresh my gradle dependencies without having to rebuild the project. I'm using Intellij and its Gradle Wrapper. I've tried running the task 'Dependencies' from IntelliJ's gradle UI, I've tried running the command gradle --refresh-dependencies AND gradlew --refresh-dependencies, both don't work. The only way to make gradle download new dependencies is to use Refresh All Gradle Project from IntelliJ UI but I don't like doing this because gradle automatically runs some tasks I don't want to run when I'm only looking to refresh the dependencies.

PentaKon
  • 4,139
  • 5
  • 43
  • 80
  • I think this question will help you http://stackoverflow.com/questions/13565082/how-can-i-force-gradle-to-redownload-dependencies I suspect it is updating up is actually loading from the cache... – saml Mar 08 '16 at 09:05
  • I don't want to delete my gradle caches to force a refresh since there is no need to (the project updates fine when I do a whole build). I just want the refresh, without having to rebuild the whole project to trigger it. – PentaKon Mar 08 '16 at 09:15
  • Did I get you right - you want to refresh your dependencies in IntelliJ IDEA? Or do you just want to download the updated dependencies to your local gradle cache? – TobiSH Mar 08 '16 at 11:08
  • with '--refresh-dependencies', Gradle will always hit the remote server to check for updated artifacts: however, Gradle will avoid downloading a file where the same file (by SHA1) already exists in the cache. add -info option to see why gradle doesn't re-download dependencies. – ayaye Mar 08 '16 at 11:25
  • There was a new dependency added in the `dependencies` closure and another dependency was changed to a newer version. Gradle would do nothing when I executed `--refresh-dependencies`. Only when I rebuilt the project did it finally work. I'm starting to believe that updating dependencies is part of the `build` process and can't be done individually. – PentaKon Mar 08 '16 at 13:24
  • I found the same thing as Konstantine. Running `gradlew --refresh-dependencies` did nothing, but running `gradlew --refresh-dependencies build` refreshed any dependencies that needed to be refreshed. – Brian Westrich Aug 15 '17 at 23:35

1 Answers1

2

Try running ./gradlew dependencies --refresh-dependencies, it will list dependencies and download them without building.

Samir Alajmovic
  • 3,247
  • 3
  • 26
  • 28