So I regularly have to clean out my `$GRADLE_USER_...
# community-support
t
So I regularly have to clean out my
$GRADLE_USER_HOME/.gradle/caches/<version>/transforms
directory which is gathering multiple gigabytes worth of duplicated transformed libraries that get generated through my multi component build. Now I know Gradle is first about correctness and speed and secondly only cares about optimizing cache sizes and the like, but I really, really would love to have some option in Gradle to clear outdated / unused caches. Not only transforms, but in general also cache folders from older Gradle versions, old cached distributions and the like. I know I could write a script and do it myself in one go, but then Gradle daemons need to be stopped properly, no new Gradle daemons must be started (otherwise Gradle stumbles upon corrupted caches) and in general I think it's Gradle's task to deal with its caches, not only creating them, but also keeping them under control. Is anything planned in this direction / is there eventually a ticket that I could subscribe to that would deal with that?
plus1 3
a
There is a configuration for cache cleanupdocs.gradle.org/current/userguide/directory_layout.html#… and there are some defaults set. If it doesn't work ok then it's worth reporting. Note that cleanup is time retention based, and not size based.
🙌 1
t
Thanks, I'll look into this!
s
Different versions of Gradle will perform maintenance on only the version-specific caches associated with each version.
It sounds like this leaves stale data behind forever after migrating to a newer Gradle version. Could later Gradle versions recognize when older versions haven't been used for a long time and then remove the stale cache data of unused Gradle versions?
a
I think this text is a bit unclear. Gradle should delete also old Gradle version folders from 4.10 (see github.com/gradle/gradle/issues/5742) This should configure deletion of
caches/<version>
and
wrapper
for released or snapshot versions:
Copy code
beforeSettings {
    caches {
        releasedWrappers.setRemoveUnusedEntriesAfterDays(30)
        snapshotWrappers.setRemoveUnusedEntriesAfterDays(7)
    }
}
I dig into it a bit and I found that it's possible cleanup is skipped for old versions if
caches/<version>/fileHashes/fileHashes.lock
is missing. If you find the same issue its worth reporting, it could be a bug or just some heuristic we are missing. Also I think it's worth opening an issue to make the documentation clearer about cleaning old Gradle versions.
v
Just trying to prevent confusion, the given settings are the defaults, so by default those should already be cleaned in those intervals.
👍 1