Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force gradle to NOT to download dependencies (and load them from it's cache instead)?

While shifting my project from Ubuntu to Mac, I copied the Java dependencies and jars from the ~/.gradle/cacheon Ubuntu to ~/.gradle/caches/artifacts on Mac to avoid having gradle download the dependencies all over again. To my surprise, running gradle idea (we are using Intellij Idea) emptied the ~/.gradle/caches/artifacts folder and started downloading the dependencies again, nevertheless

I saw numerous resources and questions on SOF talk about forcing gradle to redownload the dependencies (using the --refresh-dependencies flag, for example), but none so far on how to prevent gradle from doing that and instead look into its local cache.

Is there a flag or switch which can help achieve this task?

I am using gradle 1.0-milestone-3, and unfortunately, don't have the privilege to upgrade it anytime soon.

like image 262
satvik.t Avatar asked Oct 19 '25 15:10

satvik.t


1 Answers

There's --offline flag which prevents Gradle from accessing network resources. As a consequence it will use Gradle dependency cache and not try to refresh the dependencies from the remote server. See How to configure gradle to work "offline" (using cached dependencies).

Of course, as lance-java mentioned in his answer relocatable dependency cache is a v6.1+ feature (see Make dependency caches relocateable#1338) and therefore won't work for caches generated with earlier Gradle versions.

like image 133
jannis Avatar answered Oct 22 '25 05:10

jannis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!