Skip to content

Commit

Permalink
Improved Dokka Gradle 8 workaround for Kotlin 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdgr8 committed Jun 1, 2023
1 parent f053e40 commit 61d0577
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/base-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.configurationcache.extensions.capitalized
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
Expand Down
25 changes: 6 additions & 19 deletions buildSrc/src/main/kotlin/library-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")

import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchy.SourceSetTree
import org.jetbrains.kotlin.gradle.targets.native.internal.CInteropMetadataDependencyTransformationTask

plugins {
id("base-convention")
Expand Down Expand Up @@ -42,21 +39,11 @@ publishing.publications.withType<MavenPublication> {
}

// Workaround for https://github.com/Kotlin/dokka/issues/2977.
// We disable the C Interop IDE metadata task when generating documentation using Dokka.
gradle.taskGraph.whenReady {
val hasDokkaTasks = allTasks.any {
it is AbstractDokkaTask
}
if (hasDokkaTasks) {
tasks.withType<CInteropMetadataDependencyTransformationTask>().configureEach {
enabled = false
}
tasks.withType<AbstractDokkaTask> {
val className = "org.jetbrains.kotlin.gradle.targets.native.internal.CInteropMetadataDependencyTransformationTask"
@Suppress("UNCHECKED_CAST")
val taskClass = Class.forName(className) as Class<Task>
parent?.subprojects?.forEach {
dependsOn(it.tasks.withType(taskClass))
}
}

// TODO: Report this if it's still a bug in 1.9.0-RC
// Note in Kotlin 1.9.0-Beta-152 (1.8.21 works without this)
// transformCommonMainDependenciesMetadata needs to be run first before publishToMavenLocal
// and even still, paging modules are missing a file generated in other modules
// build/kotlinTransformedCInteropMetadataLibraries/iosMain/.couchbase-lite-paging-iosMain.cinteropLibraries
// copy from ktx modules and fix file path, then publishToMavenLocal will succeed
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mockk = "1.13.3" # 1.13.4 breaks QueryExtensionKtTest on Android https://github.
[plugins]
android-library = { id = "com.android.library", version = "7.4.2" }
dokka = { id = "org.jetbrains.dokka", version = "1.8.10" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version = "1.9.0-RC-238" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version = "1.9.0-RC-243" }

[libraries]
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.6.1" }
Expand Down

0 comments on commit 61d0577

Please sign in to comment.