Gradle plugin prototype that uses the project model 2.0

This commit is contained in:
Sergey Igushkin
2021-02-02 12:31:16 +03:00
parent d66f95b80e
commit 70b88ada93
45 changed files with 1205 additions and 176 deletions
@@ -17,13 +17,12 @@ interface KotlinModuleFragment {
// TODO: scopes
val declaredModuleDependencies: Iterable<KotlinModuleDependency>
// TODO: should this be source roots or source files?
val kotlinSourceRoots: Iterable<File>
}
interface KotlinModuleVariant : KotlinModuleFragment {
val variantAttributes: Map<KotlinAttributeKey, String>
var isExported: Boolean
}
val KotlinModuleFragment.fragmentAttributeSets: Map<KotlinAttributeKey, Set<String>>
@@ -65,7 +64,6 @@ class BasicKotlinModuleVariant(
containingModule,
fragmentName
), KotlinModuleVariant {
override var isExported: Boolean = true
override val variantAttributes: MutableMap<KotlinAttributeKey, String> = mutableMapOf()
override fun toString(): String = "variant $fragmentName"
}
@@ -9,7 +9,7 @@ class MatchVariantsByExactAttributes : ModuleVariantResolver {
override fun getChosenVariant(requestingVariant: KotlinModuleVariant, dependencyModule: KotlinModule): VariantResolution {
val candidates = dependencyModule.variants
return candidates.filter { candidate ->
candidate.isExported && candidate.variantAttributes.all { (attributeKey, candidateValue) ->
candidate.variantAttributes.all { (attributeKey, candidateValue) ->
attributeKey !in requestingVariant.variantAttributes.keys ||
candidateValue == requestingVariant.variantAttributes.getValue(attributeKey)
}