From a9dd19438321777f917a86f2fa35a25a48e2d97d Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Sat, 28 Mar 2020 12:36:30 +0300 Subject: [PATCH] Fix wrong assumption in getHostSpecificSourceSets (KMM-225) The assumption that each source set is already registered in at least one compilation would break Android targets which are configured later on the execution path, and also fail when there are unused source sets. Issue #KMM-225 Fixed --- .../kotlin/gradle/targets/native/KotlinNativeTarget.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt index c363a80e3dc..08cb41578c3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt @@ -147,6 +147,8 @@ internal fun getHostSpecificSourceSets(project: Project): List fun canBeBuiltOnHosts(konanTarget: KonanTarget) = enabledByHost.filterValues { konanTarget in it }.keys return project.kotlinExtension.sourceSets.filter { sourceSet -> + if (sourceSet !in compilationsBySourceSet) return@filter false + // If the source set participates in compilations such that some host can't run either of them, then on that host, // we can't analyze the source set, so the source set's metadata can't be published from that host, and therefore // we consider it platform-specific and publish as a part of the Native targets where the source set takes part,