Open aSemy opened 1 month ago
This issue needs a decision from the team responsible for that area. They have been informed. Response time may vary.
I think there might be a few issues tied up in this:
We want to make this better, but I'm not sure if a different resolution mode is what we want to do. We've added the appropriate labels for this, but we're not going to directly work on this right now.
Expected Behavior
When resolving a Configuration it is possible to strictly resolve based on the provided attributes.
When attribute values are mismatched, Gradle will not silently resolve random files.
If such issues occur when multiple Configurations extend each other, it's exceptionally easy to track down and diagnose the issue.
Current Behavior (optional)
When resolving a Configuration it is not possible to strictly resolve based on the provided attributes.
When attribute values are mismatched, Gradle will silently resolve random files.
If such issues occur when multiple Configurations extend each other, it's exceptionally difficult to track down and diagnose the issue.
As investigated in https://github.com/gradle/gradle/issues/27594 it is not possible to manually filter using an ArtifactView in a configuration-cache compatible way. Even if it was, the workaround is very verbose and repetitive, inviting further bugs.
Investigating mismatches is exceptionally complicated, as tools like
dependencyInsight
basically require you know what the issue is before you know it, and have UX issues, or are incompatible with composite builds.Context
Example: it is impossible to protect against mistakes
When an attribute value has a mistake, it's not easy to see what the problem is. Gradle will run without error and resolve unrequested files.
In the following example the attributes of
demoConfWindowsDebugResolver
anddemoConfWindowsDebugProvider
appear to match, so it's not clear why Gradle wouldn't resolve the correct file.Create a Gradle project with the following
build.gradle.kts
Run
./gradlew artifactViewFilesResolverTask
or./gradlew demoConfWindowsDebugResolver
.Observe that the resolved files do not match the expected value.
Ideally it would be possible to tell Gradle to match (all? some?) attributes exactly. This would trigger a resolution error, because
"Windows" != "windows"
.The mismatch can be even more obscured when the attribute values are derived from non-String values. E.g. if an attribute value is supposed to be an enum, a plugin might accidentally do
FooEnum.Windows.lowercase()
in one location, but not in another.