Registering multiple transforms with the same values of attributes should fail #26974
Labels
a:feature
A new functionality
in:artifact-transforms
re:comprehensibility
reasonable errors and warnings, clear dsl, mental overload
Current Behavior
Open the attached project: TransformWithSameAttributes.zip
It has the following transform setup (expand to see)
The idea is that we register 2 transforms with the same set of attributes (by accident), but Gradle doesn't fail, therefore causing latent errors that are hard to debug.
For example: Running
./gradlew --stop -Dgradle.user.home=gradle-user-home && rm -rf gradle-user-home/caches/transforms-3 && ./gradlew printArtifacts21 printArtifacts24 -Dgradle.user.home=gradle-user-home
will produce the following log:It shows that the transform for
minSdk = 21
didn't run, and the task:printArtifacts21
is supposed to get the transformed artifact withminSdk = 21
but it gets the transformed artifact withminSdk = 24
instead.Expected Behavior
It's easy for the users to forget to set the necessary attributes. One could say it's the responsibility of the users. But Gradle could easily help users avoid that mistake by failing the build when multiple transforms are registered with the same values of attributes.
Context (optional)
This is a simplified example of a real bug that we have in the Android Gradle plugin (https://issuetracker.google.com/293206305 - "NoClassDefFoundError with AGP 8.1.0, desugaring and minify"). When setting up L8DesugarLibTransform, we forgot to set up the
minSdkVersion
attribute even though it is an input to the transform.Steps to Reproduce
(See above)
Gradle version
8.4
Build scan URL (optional)
No response
Your Environment (optional)
No response
The text was updated successfully, but these errors were encountered: