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

Viewed 884

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.

2 Answers

This was not supported before Gradle 6.1, are you using Gradle 6.1.1 or later?

Earlier versions of Gradle included the absolute file path in each item's cache key which made it difficult to copy a build cache from one machine and use it on another.

See the Gradle 6.1.1 Release Notes regarding the relocatable build cache

Related