Task output caching is a new kind of cache mechanism in Gradle that aims to save time by, instead of executing a task, reusing results produced by previous executions of the same task with matching inputs. Reusing results can happen between builds happening in the same project, or in two different projects on the same computer, or even between builds running on different computers. Task output caching does not define the service to be used to store and retreive the results. Instead it only specifies a simple protocol that can be implemented to adopt different kinds of existing services as cache backends.
We now have sample scenarios you can try out. You can try using the local cache backend the easiest, while using an HTTP cache backend gives you the most versatility.
If you want to try the cache on your own projects, you can do so by:
- Update the wrapper in your Java project to the latest Gradle release.
- Run builds with
./gradlew --build-cache
with the local cache backend (or you can also use the HTTP backend set up in the HTTP backend sample).
We have some documentation on that.
See here how to get additional diagnostics for your build.
Task output caching currently works with a local directory as the cache backend. There is no eviction policy, so entries once added to the cache stay there indefinitely. The cache directory by default is in $GRADLE_HOME/task-cache
. It can be moved to a different location by supplying -Dorg.gradle.cache.tasks.directory=...
. This can be useful when setting up automated tests for example.