gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.92k stars 4.74k forks source link

--refresh-dependencies leaves behind configuration cache entries using old dependencies #31148

Open TheGoesen opened 1 week ago

TheGoesen commented 1 week ago

Current Behavior

given a gradle build using snapshot dependencies (changing dependencies) and configuration cache enabled. Executing multiple gradle targets will populate the gradle configuration cache. for example gradlew app:dependencyInsight --configuration runtimeClasspath --dependency myDependency later on someone want to update the dependencies and executes gradlew build --refresh-dependencies This does correctly update the dependencies. However all other gradle builds that have prior configuration-cache hits will still use the old version of the artifacts. So executing dependencyInsight again for example will result in a cache hit, showing the old version of 'myDependency'

In practice this gets very confusing as gradle will sometimes pick one version for some builds and another version for different targets... for example gradlew classes might pick the old version because it has a configuration cache hit, but then gradlew jar will pick the new version because its a configuration cache miss...

Expected Behavior

This behavior should be documented or --refresh-dependencies should also purge the configuration cache. (or at least drop all entries that are affected by the updated-dependencies)

Context (optional)

Was discussed here: https://discuss.gradle.org/t/configuration-cache-combined-with-refresh-dependencies/49786

Self-contained Reproducer Project

any good public examples for changing artifacts?

Gradle version

8.10.2

Build scan URL (optional)

No response

Your Environment (optional)

No response

reinsch82 commented 6 days ago

The issue is in the backlog of the relevant team and is prioritized by them.

mlopatkin commented 8 hours ago

First step should be to check if the vintage (non-CC) build actually picks up refreshed dependencies. If it doesn't, it should be fixed too.