Skip to content

Commit 7ec767b

Browse files
authored
build: replace empty javadoc stub with real Dokka HTML (#14)
The plugin is written in Kotlin, so the stock Java-only javadoc task produced nothing and withJavadocJar() shipped an EMPTY -javadoc.jar to Maven Central. Apply Dokka 2.2.0 and add its rendered HTML to the javadoc jar so consumers get a real API reference. Verified locally: the jar now contains 96 files / 27 HTML pages incl. index.html.
1 parent be6f8c0 commit 7ec767b

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[versions]
22
detekt = "1.23.8"
3+
dokka = "2.2.0"
34
nmcp = "1.6.1"
45

56
[plugins]
67
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version = "2.1.1" }
78
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
9+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
810
nmcp = { id = "com.gradleup.nmcp", version.ref = "nmcp" }
911

1012
[libraries]

plugin/build.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ plugins {
2121
`kotlin-dsl`
2222
alias(libs.plugins.gradle.plugin.publish)
2323
alias(libs.plugins.detekt)
24+
alias(libs.plugins.dokka)
2425
alias(libs.plugins.nmcp)
2526
signing
2627
}
@@ -36,6 +37,27 @@ java {
3637
withJavadocJar()
3738
}
3839

40+
// Populate the Maven Central -javadoc.jar with real Dokka HTML. This plugin is
41+
// written in Kotlin, so the stock (Java-only) `javadoc` task produces nothing
42+
// and withJavadocJar() would otherwise ship an empty jar. Dokka renders the
43+
// public API; its HTML output is added to the javadoc jar.
44+
dokka {
45+
moduleName.set("Gradle Flatpak Sources")
46+
dokkaSourceSets.configureEach {
47+
sourceLink {
48+
localDirectory.set(file("src/main/kotlin"))
49+
remoteUrl("https://github.com/meshtastic/gradle-flatpak-sources/blob/main/plugin/src/main/kotlin")
50+
remoteLineSuffix.set("#L")
51+
}
52+
}
53+
}
54+
55+
tasks.named<Jar>("javadocJar") {
56+
dependsOn("dokkaGeneratePublicationHtml")
57+
from(tasks.named("dokkaGeneratePublicationHtml"))
58+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
59+
}
60+
3961
detekt {
4062
buildUponDefaultConfig = true
4163
allRules = false

0 commit comments

Comments
 (0)