Fix Android Lint dependency resolution issues (KT-49483)

Android Gradle plugin resolves the *Classpath configurations in an
artifact view with an artifactType attribute set, which should
give a resolved variant with a different `org.gradle.category`
attribute. With `org.gradle.category=library` set by the Kotlin
Gradle plugin, that couldn't work.

To fix this, don't set the `org.gradle.category` attribute on the
Android resolvable configurations.

TODO: Add integration tests!
This commit is contained in:
Sergey Igushkin
2021-10-31 18:56:49 +04:00
committed by Space
parent eaff4c6026
commit 05822c59b5
3 changed files with 55 additions and 7 deletions
@@ -329,7 +329,9 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
isVisible = false
isCanBeConsumed = false
attributes.attribute(USAGE_ATTRIBUTE, KotlinUsages.consumerApiUsage(compilation.target))
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
if (compilation.platformType != KotlinPlatformType.androidJvm) {
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
}
description = "Compile classpath for $compilation."
}
@@ -359,7 +361,9 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
isCanBeConsumed = false
isCanBeResolved = true
attributes.attribute(USAGE_ATTRIBUTE, KotlinUsages.consumerRuntimeUsage(compilation.target))
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
if (compilation.platformType != KotlinPlatformType.androidJvm) {
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
}
description = "Runtime classpath of $compilation."
}
}