Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to I enable Gradle configuration cache feature persistently?

Tags:

gradle

Gradle has this new feature to cache configuration instead of recalculating it for every build. It can be enabled on the command line with --configuration-cache, but how can it be enabled persistently in a file that I would check in source control?

like image 854
Lóránt Pintér Avatar asked Jan 22 '26 20:01

Lóránt Pintér


1 Answers

The Gradle configuration cache, available starting with Gradle 6.6, not to be confused with the Gradle build cache, is a feature that significantly improves build performance by caching the result of the configuration phase and reusing this for subsequent builds.

It is conceptually similar to the build cache, but caches different information. The build cache takes care of caching the outputs and intermediate files of the build, such as task outputs or artifact transform outputs. The configuration cache takes care of caching the build configuration for a particular set of tasks. In other words, the configuration cache caches the output of the configuration phase, and the build cache caches the outputs of the execution phase.

The configuration cache can be enabled from the command line:

❯ gradle --configuration-cache build

It can also be enabled persistently in a gradle.properties file that you can check into source control:

org.gradle.unsafe.configuration-cache=true

or if you're on Gradle 8.1+ where the feature is stable:

org.gradle.configuration-cache=true

If it is enabled in a gradle.properties file, it can be disabled on the command line for one build invocation:

❯ gradle --no-configuration-cache build

See the official documentation for more command line and gradle.properties options: https://docs.gradle.org/nightly/userguide/configuration_cache.html

like image 170
eskatos Avatar answered Jan 24 '26 18:01

eskatos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!