Revert "(minor) Transform KotlinPlatformType attribute to String, rename entries"

This reverts commit 3f24f8bd
This commit is contained in:
Sergey Igushkin
2018-09-26 15:50:22 +03:00
parent 8d054ba346
commit 44f87e4951
8 changed files with 33 additions and 33 deletions
@@ -10,43 +10,43 @@ import org.gradle.api.attributes.*
import org.gradle.util.GradleVersion
import java.io.Serializable
enum class KotlinPlatformType(val attributeValue: String): Named, Serializable {
COMMON("common"), JVM("jvm"), JS("js"), ANDROID_JVM("androidJvm"), NATIVE("native");
enum class KotlinPlatformType: Named, Serializable {
common, jvm, js, androidJvm, native;
override fun toString(): String = name
override fun getName(): String = name
class CompatibilityRule : AttributeCompatibilityRule<String> {
override fun execute(details: CompatibilityCheckDetails<String?>) = with(details) {
if (producerValue == JVM.attributeValue && consumerValue == ANDROID_JVM.attributeValue)
class CompatibilityRule : AttributeCompatibilityRule<KotlinPlatformType> {
override fun execute(details: CompatibilityCheckDetails<KotlinPlatformType>) = with(details) {
if (producerValue == jvm && consumerValue == androidJvm)
compatible()
// Allow the input metadata configuration consume platform-specific artifacts if no metadata is available, KT-26834
if (consumerValue == COMMON.attributeValue)
if (consumerValue == common)
compatible()
}
}
class DisambiguationRule : AttributeDisambiguationRule<String> {
override fun execute(details: MultipleCandidatesDetails<String?>) = with(details) {
if (candidateValues == setOf(ANDROID_JVM.attributeValue, JVM.attributeValue))
closestMatch(ANDROID_JVM.attributeValue)
class DisambiguationRule : AttributeDisambiguationRule<KotlinPlatformType> {
override fun execute(details: MultipleCandidatesDetails<KotlinPlatformType?>) = with(details) {
if (candidateValues == setOf(androidJvm, jvm))
closestMatch(androidJvm)
if (COMMON.attributeValue in candidateValues)
if (common in candidateValues)
// then the consumer requests common or requests no platform-specific artifacts,
// so common is the best match, KT-26834
closestMatch(COMMON.attributeValue)
closestMatch(common)
}
}
companion object {
val ATTRIBUTE = Attribute.of(
val attribute = Attribute.of(
"org.jetbrains.kotlin.platform.type",
String::class.java
KotlinPlatformType::class.java
)
fun setupAttributesMatchingStrategy(attributesSchema: AttributesSchema) {
attributesSchema.attribute(KotlinPlatformType.ATTRIBUTE).run {
attributesSchema.attribute(KotlinPlatformType.attribute).run {
if (isGradleVersionAtLeast(4, 0)) {
compatibilityRules.add(CompatibilityRule::class.java)
disambiguationRules.add(DisambiguationRule::class.java)