Paulo Cereda
10/16/2025, 5:40 PMPaulo Cereda
10/16/2025, 5:41 PMjavadoc.jar for our libraries:
named<DokkaTask>("dokkaHtml").let { documentation ->
documentation.configure {
dokkaSourceSets.configureEach {
// configuration here ...
sourceLink {
// ...
}
}
}
register<Jar>("javadocJar") {
dependsOn(documentation)
archiveClassifier.set("javadoc")
from(documentation.flatMap { it.outputDirectory })
}
}
And then, at some point:
publishing {
publications {
withType<MavenPublication> {
artifact(tasks.named("javadocJar"))
...
}
}
}
I managed to configure our code to dokka 2.1.0, but the part of generating the javadoc.jar artifact was missing. I checked the documentation and the suggested code didn't work (not sure if it was updated), so any suggestions are welcome. πPaulo Cereda
10/16/2025, 5:42 PMPaulo Cereda
10/16/2025, 9:07 PMregister<Jar>("javadocJar") {
named<DokkaGeneratePublicationTask>("dokkaGeneratePublicationJavadoc").let { documentation ->
dependsOn(documentation)
from(documentation.flatMap { it.outputDirectory })
}
archiveClassifier.set("javadoc")
}
And it seems to work, but I am not sure this is the official way... π
Oleg Yukhnevich
10/17/2025, 12:56 PMPaulo Cereda
10/17/2025, 3:46 PMpublish task to have our library>-javadoc.jar built as well (the default behaviour only generates the library binary itself and sources, but not documentation).Oleg Yukhnevich
10/17/2025, 4:04 PMPaulo Cereda
10/17/2025, 4:30 PMAdam Semenenko
10/22/2025, 8:50 AMregister<Jar>("javadocJar") {
val dokkaGeneratePublicationJavadoc = named<DokkaGeneratePublicationTask>("dokkaGeneratePublicationJavadoc")
from(dokkaGeneratePublicationJavadoc)
archiveClassifier.set("javadoc")
}
Gradle will automatically use the output of the dokkaGeneratePublicationJavadoc task, and automatically infer the task dependencies.
I'll update the example to remove the unnecessary .flatMap { it.outputDirectory }...Paulo Cereda
10/22/2025, 10:37 AM