Skip to content

Commit

Permalink
Ignore compatibility metadata variant if HMPP is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev committed Aug 22, 2022
1 parent e9e95f6 commit 843df6e
Showing 1 changed file with 16 additions and 1 deletion.
Expand Up @@ -6,13 +6,28 @@ 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
.map { compilation -> compileClasspathOf(compilation) }
.mapNotNull { compilation ->
/**
* 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`
*/
if (isHMPPEnabled && compilation is KotlinCommonCompilation && compilation.name == "main") null
else compileClasspathOf(compilation)
}
.reduce { acc, fileCollection -> acc + fileCollection }
} else {
sourceSet.withAllDependentSourceSets()
Expand Down

0 comments on commit 843df6e

Please sign in to comment.