Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force gradle to redownload dependencies?

Tags:

gradle

How can I tell gradle to redownload dependencies from repositories?

like image 495
fedor.belov Avatar asked Nov 26 '12 12:11

fedor.belov


People also ask

How do I resolve Gradle dependencies?

Obtaining module metadata Given a required dependency, with a version, Gradle attempts to resolve the dependency by searching for the module the dependency points at. Each repository is inspected in order. Depending on the type of repository, Gradle looks for metadata files describing the module ( .


1 Answers

Generally, you can refresh dependencies in your cache with the command line option --refresh-dependencies. You can also delete the cached files under ~/.gradle/caches. With the next build Gradle would attempt to download them again.

What is your specific use case? Do you use dynamic dependency versions or SNAPSHOT versions?


On Unix systems, you can delete all the existing artifacts (artifacts and metadata) Gradle has downloaded using:

rm -rf $HOME/.gradle/caches/ 

Note that --refresh-dependencies won't always re-download every artifact; it will use existing copies if they match what exists in the repository. From the Gradle User Guide, refreshing dependencies:

The --refresh-dependencies option tells Gradle to ignore all cached entries for resolved modules and artifacts. A fresh resolve will be performed against all configured repositories, with dynamic versions recalculated, modules refreshed, and artifacts downloaded. However, where possible Gradle will check if the previously downloaded artifacts are valid before downloading again. This is done by comparing published SHA1 values in the repository with the SHA1 values for existing downloaded artifacts.

[...]

It’s a common misconception to think that using --refresh-dependencies will force download of dependencies. This is not the case: Gradle will only perform what is strictly required to refresh the dynamic dependencies. This may involve downloading new listing or metadata files, or even artifacts, but if nothing changed, the impact is minimal.

like image 79
Benjamin Muschko Avatar answered Oct 12 '22 23:10

Benjamin Muschko