The local gradle cache stores copies of maven/gradle dependencies. How to clear gradle cache? covers how to clear the whole cache, but not individual packages.
Is there a simple way to remove one package from the local gradle cache? This would be useful, for example, when actively developing a library. To test a minor library change, I currently have to clear the entire cache from the filesystem so an old cached version of the library is not used.
I understand it is also possible to use the gradle ResolutionStrategy described in How can I force gradle to redownload dependencies?. I would prefer not to change the gradle configuration because most of the time and for most developers, the default caching behavior is fine.
So here's a quick script I whipped up:
seekanddestroy.gradle
You can invoke this script by running
gradle -b seekanddestroy.gradle
Demo of how it works: if your build.gradle looks like this:
First time build, includes a download of the dependency:
Second clean build, uses cached dependency, so no download:
Now run seekanddestroy:
Next build, downloads dependency again: