Skip to content

Commit 75f1f69

Browse files
authored
Merge pull request #11 from javalin/build/dokka-javadoc
Render the javadoc jar with Dokka
2 parents df92e35 + ce74831 commit 75f1f69

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ is a breaking change; the README has a
7474
incompatible major, and it requested a `renderExample.js` that does not exist.
7575
- Building the plugin without registering a package now fails saying so, instead of scanning
7676
the package `kotlin.Unit`, which is a class and matches nothing.
77+
- The published `javadoc` jar contained nothing but a manifest, because it was built from the
78+
`javadoc` task and every source file is Kotlin. It is now rendered by Dokka.
7779

7880
Set the date and add the release link below when the `v7.0.0` tag is cut.
7981

‎build.gradle.kts‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ plugins {
44
`maven-publish`
55
kotlin("jvm") version "2.2.20"
66
id("io.gitlab.arturbosch.detekt") version "1.23.8"
7+
id("org.jetbrains.dokka") version "2.2.0"
8+
id("org.jetbrains.dokka-javadoc") version "2.2.0"
79
}
810

911
detekt {
@@ -27,6 +29,23 @@ repositories {
2729
mavenCentral()
2830
}
2931

32+
java {
33+
withJavadocJar()
34+
withSourcesJar()
35+
}
36+
37+
// `withJavadocJar()` fills the jar from the `javadoc` task, which has no Java source to read
38+
// here, so what shipped was 261 bytes containing nothing but a manifest. Dokka renders the KDoc
39+
// instead — the API this artifact documents is Kotlin.
40+
//
41+
// The jar is redirected rather than replaced by one of our own: `withJavadocJar()` is also what
42+
// registers the `javadocElements` variant, so a consumer resolving through Gradle module
43+
// metadata still finds the documentation. Declaring a separate task would publish the jar to
44+
// Maven and leave that variant missing.
45+
tasks.named<Jar>("javadocJar") {
46+
from(tasks.dokkaGeneratePublicationJavadoc)
47+
}
48+
3049
publishing {
3150
publications {
3251
create<MavenPublication>("library") {
@@ -93,11 +112,6 @@ tasks.withType<JavaCompile>().configureEach {
93112
options.release.set(17)
94113
}
95114

96-
java {
97-
withJavadocJar()
98-
withSourcesJar()
99-
}
100-
101115
dependencies {
102116
// All of these appear in this plugin's public API, so they belong on the consumer's
103117
// compile classpath: Javalin's Context and WsMessageContext in the builder and the

0 commit comments

Comments
 (0)