Until now I was using this to get list of all dependencies
runtimeConfiguration.resolvedConfiguration.lenientConfiguration.allModuleDependencies.forEach { dependency: ResolvedDependency ->
dependency.moduleArtifacts.forEach { artifact: ResolvedArtifact ->
val newDep = MavenCoordinates(
dependency.moduleGroup, dependency.moduleName,
dependency.moduleVersion, artifact.type, artifact.classifier
)
But it started to causing this Error. I found that old way is now deprecated,
Caused by: org.gradle.internal.component.AmbiguousVariantSelectionException: The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr
' with value 'debug', attribute 'basic' with value 'demo', attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar', attribute 'org.jetbrains.kotlin.platform.type' with value
'androidJvm'. However we cannot choose between the following variants of project :sample-library:
- Configuration ':sample-library:debugRuntimeElements' variant android-assets declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', at
tribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-assets' but the consumer didn't ask for it
- Doesn't say anything about basic (required 'demo')
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
So I started using this
runtimeConfiguration.incoming.artifactView {
isLenient = true
}.artifacts.forEach {
val artifact =
it.id.componentIdentifier as org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier
val newDep = MavenCoordinates(
artifact.group,
artifact.module,
artifact.version,
it.variant.attributes.getAttribute(Attribute.of("artifactType", String::class.java))!!,
null
)
It also failing, but only when isLenient is false, but with true it works.
But I can access maven classifier from this API please?