From 55883b58114fa569bdd3280375596fef42a8cb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Sun, 12 Nov 2023 21:49:48 +0100 Subject: [PATCH] Publish dokka docs --- gradle/libs.versions.toml | 2 ++ gradle/plugins/build.gradle | 4 ++++ .../plugins/src/main/kotlin/PublishingPlugin.kt | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 50561f2..921a9c7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,6 +8,7 @@ maven-kotlin = "1.9.20" maven-junit = "5.10.1" maven-assertj = "3.24.2" maven-binarycompatiblity = "0.13.2" +maven-dokka = "1.9.10" [libraries] junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "maven-junit" } @@ -20,6 +21,7 @@ com-squareup-kotlinpoet = "com.squareup:kotlinpoet:1.14.2" kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "maven-kotlin-serialization" } kotlinx-serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version.ref = "maven-kotlin-serialization" } com-squareup-okio = "com.squareup.okio:okio:3.6.0" +jetbrains-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "maven-dokka" } [plugins] starter-config = { id = "com.starter.config", version.ref = "gradle-starter" } diff --git a/gradle/plugins/build.gradle b/gradle/plugins/build.gradle index 0aab13a..7cee867 100644 --- a/gradle/plugins/build.gradle +++ b/gradle/plugins/build.gradle @@ -17,6 +17,10 @@ tasks.withType(KotlinCompile).configureEach { kotlinOptions.jvmTarget = targetJavaVersion } +dependencies { + implementation libs.jetbrains.dokka +} + gradlePlugin { plugins { publishingPlugin { diff --git a/gradle/plugins/src/main/kotlin/PublishingPlugin.kt b/gradle/plugins/src/main/kotlin/PublishingPlugin.kt index e43dc81..0ce8a6a 100644 --- a/gradle/plugins/src/main/kotlin/PublishingPlugin.kt +++ b/gradle/plugins/src/main/kotlin/PublishingPlugin.kt @@ -4,8 +4,10 @@ import org.gradle.api.plugins.ExtensionContainer import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication +import org.gradle.jvm.tasks.Jar import org.gradle.plugin.devel.GradlePluginDevelopmentExtension import org.gradle.plugins.signing.SigningExtension +import org.jetbrains.dokka.gradle.DokkaTask class PublishingPlugin : Plugin { @@ -14,6 +16,7 @@ class PublishingPlugin : Plugin { if (findConfig("SIGNING_PASSWORD").isNotEmpty()) { pluginManager.apply("signing") } + extensions.configure { with(repositories) { maven { maven -> @@ -59,7 +62,20 @@ class PublishingPlugin : Plugin { pluginManager.withPlugin("java") { extensions.configure { withSourcesJar() + withJavadocJar() } + + pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + pluginManager.apply("org.jetbrains.dokka") + + tasks.withType(DokkaTask::class.java).configureEach { dokkaTask -> + dokkaTask.notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/1217") + } + tasks.named("javadocJar", Jar::class.java) { javadocJar -> + javadocJar.from(tasks.named("dokkaJavadoc")) + } + } + extensions.configure { publications.configureEach { publication -> (publication as? MavenPublication)?.pom { pom ->