I started to see the error mentioned in :thread: w...
# gradle
r
I started to see the error mentioned in 🧵 while trying to upgrade our project to Gradle-9. Warning turned error (https://docs.gradle.org/9.0.0/userguide/upgrading_version_8.html#deprecated_ambiguous_transformation_chains) in Gradle-9, when there are multiple artifact transformation chain to chose from for same requested attribute. Digging more - https://github.com/google/dagger/issues/4847 seems like it needs to be fixed from dagger end. I was wondering if at consumer end we can add a fix until it's fixed in upstream.
Copy code
Caused by: org.gradle.internal.component.resolution.failure.exception.ArtifactSelectionException: Found multiple transformation chains that produce a variant of 'project :primitives:cart-checkout' with requested attributes:	
  - artifactType 'jar-for-dagger'	
  - com.android.build.api.attributes.AgpVersionAttr '8.10.1'	
  - com.android.build.api.attributes.BuildTypeAttr 'release'	
  - org.gradle.category 'library'	
  - org.gradle.jvm.environment 'android'	
  - org.gradle.usage 'java-runtime'	
  - org.jetbrains.kotlin.platform.type 'androidJvm'	
Found the following transformation chains:	
  - From configuration ':primitives:cart-checkout:releaseRuntimeElements' variant 'android-classes-jar':	
      - With source attributes:	
          - artifactType 'android-classes-jar'	
          - com.android.build.api.attributes.AgpVersionAttr '8.10.1'	
          - com.android.build.api.attributes.BuildTypeAttr 'release'	
          - com.android.build.gradle.internal.attributes.VariantAttr 'release'	
          - org.gradle.category 'library'	
          - org.gradle.jvm.environment 'android'	
          - org.gradle.libraryelements 'jar'	
          - org.gradle.usage 'java-runtime'	
          - org.jetbrains.kotlin.platform.type 'androidJvm'	
      - Candidate transformation chains:	
          - Transformation chain: 'IdentityTransform' -> 'CopyTransform':	
              - 'IdentityTransform':	
                  - Converts from attributes:	
                      - artifactType 'android-classes-jar'	
                  - To attributes:	
                      - artifactType 'android-classes'	
              - 'CopyTransform':	
                  - Converts from attributes:	
                      - artifactType 'android-classes'	
                  - To attributes:	
                      - artifactType 'jar-for-dagger'
v
From a quick look I'd say this is a Gradle bug. The explanatory doc shows two transforms are registered that can transform blue to red, resulting in identical transform chains, attribute-wise. But if some libraries have a blue variant and some a yellow variant and the is a transform that can transform either to red, that should be fine. If a library has blue and yellow variant it now fails, but imho there should be some way of chain-disambiguation rule instead that allows to consistently pick. In the meantime from the naming of the transforms, one chain contains a transform that just changes the attributes, so you should be able to register a transform that short-circuits and thus is selected for being shorter.
r
Yeah, reading the docs and see if at consumer end i can pick one to unblock myself until this https://github.com/google/dagger/issues/4847 is fixed from dagger end.
I do see some work happening there - https://github.com/google/dagger/pull/4892/files but latest snapshot of that library doesn't fix it. So either wait or try few things at consumer end.
v
The chains seem strange anyway actually. In the issue you linked there is the chain
IdentityTransform -> CopyTransform -> AggregatedPackagesTransform
and
UnzipTransform -> CopyTransform -> AggregatedPackagesTransform
IdentityTransform and CopyTransform are both identity transforms, just changing the attributes. So actually the chains could also be
AggregatedPackagesTransform
and
UnzipTransform -> AggregatedPackagesTransform
directly which would solve the ambiguity. And as a consumer-side work-around you can simply register those chains as shorter chain wins over longer chain.
👀 1
The PR you mentioned adds yet another transform
CopyTransform -> AggregatedPackagesTransform
which skips the identity transform in the first chain I mentioned. So actually it should also "fix" the issue even though the chain could be even shorter.
👍 1
r
Thank you - giving it a look.
v
I also opened https://github.com/gradle/gradle/issues/34748, maybe there will be something in the future 🤷‍♂️
gratitude thank you 1