From c37c9716857d78589a9e6faba27d2c596f2384de Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Thu, 25 Aug 2022 18:23:41 +0300 Subject: Ignore compatibility metadata variant if HMPP is enabled (#2634) --- .../jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 { -- cgit