From dd8531eba9dc9d0b540df13102dc25e91b9bb21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Muller?= Date: Mon, 6 May 2024 10:52:24 +0200 Subject: [PATCH] Integrate Dokka (#529) --- ...PillarboxAndroidLibraryPublishingPlugin.kt | 22 ++++++++++++++++++- build.gradle.kts | 1 + gradle.properties | 3 ++- gradle/libs.versions.toml | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/PillarboxAndroidLibraryPublishingPlugin.kt b/build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/PillarboxAndroidLibraryPublishingPlugin.kt index 417378e3a..14dd7e60e 100644 --- a/build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/PillarboxAndroidLibraryPublishingPlugin.kt +++ b/build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/PillarboxAndroidLibraryPublishingPlugin.kt @@ -10,6 +10,7 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication +import org.gradle.jvm.tasks.Jar import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.register @@ -21,6 +22,23 @@ class PillarboxAndroidLibraryPublishingPlugin : Plugin { override fun apply(target: Project) = with(target) { pluginManager.apply("com.android.library") pluginManager.apply("org.gradle.maven-publish") + pluginManager.apply("org.jetbrains.dokka") + + val dokkaHtmlJar = tasks.register("dokkaHtmlJar") { + val dokkaHtmlTask = tasks.named("dokkaHtml") + + dependsOn(dokkaHtmlTask) + from(dokkaHtmlTask.map { it.outputs }) + archiveClassifier.set("html-docs") + } + + val dokkaJavadocJar = tasks.register("dokkaJavadocJar") { + val dokkaJavadocTask = tasks.named("dokkaJavadoc") + + dependsOn(dokkaJavadocTask) + from(dokkaJavadocTask.map { it.outputs }) + archiveClassifier.set("javadoc") + } extensions.configure { defaultConfig { @@ -31,7 +49,6 @@ class PillarboxAndroidLibraryPublishingPlugin : Plugin { publishing { singleVariant("release") { withSourcesJar() - withJavadocJar() } } } @@ -39,6 +56,9 @@ class PillarboxAndroidLibraryPublishingPlugin : Plugin { extensions.configure { publications { register("gpr") { + artifact(dokkaHtmlJar) + artifact(dokkaJavadocJar) + afterEvaluate { from(components["release"]) } diff --git a/build.gradle.kts b/build.gradle.kts index 5d977720d..f7257db42 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,7 @@ plugins { alias(libs.plugins.kotlin.parcelize) apply false alias(libs.plugins.detekt) alias(libs.plugins.dependency.analysis.gradle.plugin) + alias(libs.plugins.dokka) apply false alias(libs.plugins.kotlinx.kover) } diff --git a/gradle.properties b/gradle.properties index 05f904976..7158b7907 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,4 +23,5 @@ android.useAndroidX=true kotlin.code.style=official org.gradle.caching=true -org.gradle.configuration-cache=true +# Disable configuration cache until Dokka supports it: https://github.com/Kotlin/dokka/issues/2231 +org.gradle.configuration-cache=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e7a18ea3a..ff699211f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,6 +21,7 @@ coil = "2.6.0" comscore = "6.11.1" dependency-analysis-gradle-plugin = "1.31.0" detekt = "1.23.6" +dokka = "1.9.20" guava = "32.1.3-android" json = "20240303" junit = "4.13.2" @@ -139,6 +140,7 @@ android-application = { id = "com.android.application", version.ref = "android-g android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" } dependency-analysis-gradle-plugin = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependency-analysis-gradle-plugin" } detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }