aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt
index 1d0fa4a3..b934d206 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt
@@ -6,12 +6,25 @@ import org.jetbrains.dokka.gradle.isAndroidTarget
import org.jetbrains.dokka.utilities.cast
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
+import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinCommonCompilation
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+val Project.isHMPPEnabled
+ // [KotlinCommonCompilation.isKlibCompilation] is internal, so we use this
+ get() = (this.findProperty("kotlin.mpp.enableGranularSourceSetsMetadata") as? String)?.toBoolean() ?: false
+
internal fun Project.classpathOf(sourceSet: KotlinSourceSet): FileCollection {
val compilations = compilationsOf(sourceSet)
return if (compilations.isNotEmpty()) {
compilations
+ /**
+ * If the project has enabled Compatibility Metadata Variant (produces legacy variant),
+ * we don't touch it due to some dependant library
+ * might be published without Compatibility Metadata Variant.
+ * Dokka needs only HMPP variant
+ * Ignore [org.jetbrains.kotlin.gradle.plugin.mpp.KotlinCommonCompilation] for `commonMain` sourceSet with name `main`
+ */
+ .filterNot { compilation -> isHMPPEnabled && compilation is KotlinCommonCompilation && compilation.name == "main" }
.map { compilation -> compileClasspathOf(compilation) }
.reduce { acc, fileCollection -> acc + fileCollection }
} else {