Skip to content

Finer grained CC invalidation for Gradle properties provided in the command line #34019

@bamboo

Description

@bamboo

Related: #20969


Currently, any changes to -P command-line properties will invalidate the configuration cache, regardless of whether the changed properties are actually used at configuration-time or not.

Consider the following simple Kotlin DSL example:

tasks.register("echo") {
    val value = providers.gradleProperty("value")
    doLast {
        println("value: ${value.orNull}")
    }
}

Multiple executions of the echo task with different -P arguments will be unable to reuse the configuration cache:

$ gradle --configuration-cache echo -Pvalue=1
Calculating task graph as no cached configuration is available for tasks: echo

> Task :echo
value: 1

...
Configuration cache entry stored.

$ gradle --configuration-cache echo -Pvalue=2
Calculating task graph as configuration cache cannot be reused because the set of Gradle properties has changed: the value of 'value' was changed.

> Task :echo
value: 2

...
Configuration cache entry stored.

Since the value property is never mentioned at configuration time, Gradle should be able to reuse the configuration cache for faster builds:

$ gradle --configuration-cache echo -Pvalue=1
Calculating task graph as no cached configuration is available for tasks: echo

> Task :echo
value: 1

...
Configuration cache entry stored.

$ gradle --configuration-cache echo -Pvalue=2
Reusing configuration cache.

> Task :echo
value: 2

...
Configuration cache entry reused.

In addition, the Configuration Cache report should also include properties used at configuration-time in the Build configuration inputs tab.


Preparation: #32471

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions