I've heard that Gradle performs automatic cleanup of caches that are not in use for some time https://github.com/gradle/gradle/issues/1085.
I have a few specific questions on how this works.
Use-case: We're using CircleCI, its Gradle Orb currently caches paths ~/.gradle/caches
and ~/.gradle/wrapper
based on a hash of the build.gradle
files on the current branch, so any (big or small) change to those files effectively wipes the cache (as it can no long be found). This causes delays / a lot of bandwidth use.
It would be possible apply the git history to get hold of the previous cache, but that would cause the cache to grow over time, as library versions are bumped. Cache save / restore will consume as much time as redownloading the dependencies long before 30 days for active development.
So we really need this cleanup feature to speed up our day-to-day operations; manual invocation of clearing "not used since" artifacts would go a long way (this can currently be done in Maven by just checking file access).
Will this work in a CI environment where I pass the "$GRADLE_USER_HOME/caches" folder between machines? Are there any additional files/folders I need to pass (e.g., files which store "last-use" timestamps)?
The last-use information is stored in $GRADLE_USER_HOME/caches/journal-1
. Thus, if you include that, it should work.
Does it work for dependencies only, or task output cache as well?
Both.
manual invocation of clearing "not used since" artifacts would go a long way
For that you'll need #7018.