autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.66k stars 116 forks source link

Could not resolve project -> when a submodule is aar artifact #1176

Closed brianPlummer closed 1 month ago

brianPlummer commented 2 months ago

Build scan link

Plugin version 1.31.0

Gradle version 8.7

JDK version 17.0.6

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version 1.9.23

(Optional) Android Gradle Plugin (AGP) version 8.3.2

Describe the bug ./gradlew app:projectHealth produces the output:

Could not determine the dependencies of task ':selfprofile:transformReleaseClassesWithAsm'.
> Could not resolve all task dependencies for configuration ':selfprofile:releaseRuntimeClasspath'.
   > Could not resolve project :laboratory-lib.
     Required by:
         project :selfprofile
         project :selfprofile > project :core-ui
         project :selfprofile > project :core-data
         project :selfprofile > project :core-common
      > The consumer was configured to find a library for use during runtime, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.3.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :laboratory-lib:
          - projectHealthElements
          - resolvedDepsElements
        All of them match the consumer attributes:
          - Variant 'projectHealthElements' capability Foo:laboratory-lib:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.3.2')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
                  - Doesn't say anything about its usage (required runtime)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
                  - Provides attribute 'dagp.internal.artifacts' with value 'project-health' but the consumer didn't ask for it
          - Variant 'resolvedDepsElements' capability Foo:laboratory-lib:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.3.2')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
                  - Doesn't say anything about its usage (required runtime)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
                  - Provides attribute 'dagp.internal.artifacts' with value 'resolved-deps' but the consumer didn't ask for it

To Reproduce Create a project with a submodule that is just an aar wrapper. With a build.gradle.kts like

configurations.maybeCreate("default")
artifacts.add("default", file("some.aar"))

Expected behavior ./gradlew app:projectHealth should output the health report

autonomousapps commented 2 months ago

Thanks for the report. Do you have a minimal reproducer?

Kernald commented 1 month ago

While I don't have a minimal reproducer, I'm facing a similar issue which seems to be a regression in 1.28.0 onwards - I tested (successfully) 1.25.0, 1.26.0 and 1.27.0, and faced the issue with both 1.28.0, 1.29.0, 1.30.0 and 1.31.0.

autonomousapps commented 1 month ago

This duplicates https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1108. Closing in favor of the latter (I have a workaround posted there).