Skip to content

Commit 3c6386c

Browse files
timofey-soloninSpace Team
authored andcommitted
Restore library category in legacy KMP publication
This will avoid no attributes configuration from resolving fallback variant over the JVM variant ^KT-81412
1 parent b263054 commit 3c6386c

File tree

2 files changed

+459
-1
lines changed

2 files changed

+459
-1
lines changed

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/uklibs/consumption/UklibConsumptionSetupAction.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ private fun Project.setupUklibConsumption() {
7171
workaroundLegacySkikoResolutionKT77539()
7272
workaroundKotlinTestJsResolutionKT81387()
7373
registerGenericFallbackVariantInAllComponentsKT81412()
74+
makeConfigurationsWithoutAttributesPreferJvmVariantsInKmpPublicationsWithoutCategoryKT81488()
7475
}
7576

7677
private fun Project.allowPlatformCompilationsToResolvePlatformCompilationArtifactFromUklib(
@@ -353,6 +354,23 @@ private fun Project.registerGenericFallbackVariantInAllComponentsKT81412() {
353354
}
354355
}
355356

357+
private fun Project.makeConfigurationsWithoutAttributesPreferJvmVariantsInKmpPublicationsWithoutCategoryKT81488() {
358+
dependencies.components.all {
359+
it.withVariant("jvmApiElements-published") {
360+
it.attributes.attribute(
361+
Category.CATEGORY_ATTRIBUTE,
362+
project.categoryByName(Category.LIBRARY),
363+
)
364+
}
365+
it.withVariant("jvmRuntimeElements-published") {
366+
it.attributes.attribute(
367+
Category.CATEGORY_ATTRIBUTE,
368+
project.categoryByName(Category.LIBRARY),
369+
)
370+
}
371+
}
372+
}
373+
356374
private class AllowPlatformConfigurationsToFallBackToMetadataAndJvmForLenientKmpResolution : AttributeCompatibilityRule<KotlinPlatformType> {
357375
override fun execute(details: CompatibilityCheckDetails<KotlinPlatformType>) = with(details) {
358376
consumerValue?.name ?: return@with

0 commit comments

Comments
 (0)