Fix resolving an MPP dependency in custom configurations (KT-32239)

In the `KotlinPlatformType` disambiguation rule, don't prefer `common`
when there's a `jvm` or an `androidJvm` variant, as this would conflict
with disambiguation rules created by the other plugins, such as Gradle's
`java` which will choose `org.gradle.usage=java-api` and lead to
ambiguity.

Issue #KT-32239 Fixed
This commit is contained in:
Sergey Igushkin
2020-07-11 18:18:39 +04:00
parent 8158ba2be3
commit aebca19fd7
2 changed files with 26 additions and 2 deletions
@@ -32,10 +32,12 @@ enum class KotlinPlatformType: Named, Serializable {
if (candidateValues == setOf(androidJvm, jvm))
closestMatch(androidJvm)
if (common in candidateValues)
if (common in candidateValues && jvm !in candidateValues && androidJvm !in candidateValues) {
// then the consumer requests common or requests no platform-specific artifacts,
// so common is the best match, KT-26834
// so common is the best match, KT-26834; apply this rule only when no JVM variant is available,
// as doing otherwise would conflict with Gradle java's disambiguation rules and lead to KT-32239
closestMatch(common)
}
}
}