Do Lazy Properties play a key role in the Configuration Cache? Or are they completely orthogonal? Here’s how I would answer the question, but I don’t know if I’m right: Lazy Properties have multiple benefits, not just work avoidance on property level (in contrast to configuration cache that can avoid the entire configuration phase). The Configuration Cache requires reliable task configuration details, so that task properties, dependencies, and build logic are stable, predictable, and serializable. As far as I know, Lazy Properties do help with this:
- Lazy properties defer work that don’t need to be calculated at configuration time, which optimizes caching by reducing the data needed to be cached.
- Also they help in ordering problems like the well-known
project.afterEvaluateanti-pattern, which we know it does not scale, so they helps with the correctness of configuration caching. - I guess lazy properties are also made with serialization in mind, although we know that a Provider can be anything, so for example,
Property<URL>is warned by Gradle 8.13 that for reliable serializability it should be something else likeProperty<URI>(see Dealing with validation problems), but Gradle would warn even if the type was just simplyURL, without the lazy property. - Lazy property values are finalized after configuration so that they can’t change during execution, this ensures correctness of the task graph, which also helps the correctness of caching.
So am in the right direction or am I wrong? What would be the right explanation? I couldn’t find documentation that clearly explains the question.
Thank you for your response.