The following is written in Gradle's documentation:
Gradle will periodically clean-up the local cache directory by removing entries that have not been used recently to conserve disk space.
When does Gradle perform this clean-up?
Is this only done when the Gradle daemon is running in the background of the operating system?
Or is this done as part of regular Gradle builds?
You practically always run with the Gradle daemon anyway, even if you use --no-daemon
or the according property in most cases a daemon still is started due to JVM options needed, just shut down after one build.
So yes, the cleanup is also done when just executing regular builds and you do not need to run any separate daemon in the background.