Skip to content

Commit c749ead

Browse files
committed
Publish KDoc for the Kotlin DSL
Applies Dokka to any subproject using security-kotlin via DocsPlugin, aggregates KDoc alongside Javadoc in syncAntoraAttachments, and adds a Kotlin API entry to the reference docs navigation. Closes gh-18968 Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
1 parent 622f75d commit c749ead

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

buildSrc/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id "groovy-gradle-plugin"
44
id "java"
55
id "groovy"
6+
id "org.jetbrains.dokka" version "2.1.0"
67
}
78

89
java {
@@ -79,6 +80,7 @@ dependencies {
7980
implementation libs.io.spring.javaformat.spring.javaformat.gradle.plugin
8081
implementation libs.io.spring.nohttp.nohttp.gradle
8182
implementation libs.org.jetbrains.kotlin.kotlin.gradle.plugin
83+
implementation libs.org.jetbrains.dokka.dokka.gradle.plugin
8284
implementation (libs.net.sourceforge.htmlunit) {
8385
exclude group: 'org.eclipse.jetty.websocket', module: 'websocket-client'
8486
}

buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,32 @@ public class DocsPlugin implements Plugin<Project> {
1919
PluginManager pluginManager = project.getPluginManager();
2020
pluginManager.apply(BasePlugin);
2121
pluginManager.apply(JavadocApiPlugin);
22+
pluginManager.apply("org.jetbrains.dokka");
23+
24+
project.rootProject.subprojects { subproject ->
25+
subproject.pluginManager.withPlugin("security-kotlin") {
26+
subproject.pluginManager.apply("org.jetbrains.dokka")
27+
configureDokka(subproject)
28+
project.dependencies.add("dokka", subproject)
29+
}
30+
}
31+
32+
project.extensions.configure("dokka") { dokka ->
33+
dokka.moduleName.set(Utils.getProjectName(project) + " Kotlin API")
34+
}
35+
36+
project.tasks.named("dokkaGeneratePublicationHtml").configure { it.dependsOn("api") }
2237

2338
project.tasks.register("syncAntoraAttachments", Sync) { sync ->
2439
sync.group = 'Documentation'
2540
sync.description = 'Syncs the Antora attachments'
26-
sync.from(project.provider({ project.tasks.api.outputs }))
27-
sync.into(project.layout.buildDirectory.dir('generated-antora-resources/modules/ROOT/assets/attachments/api/java'))
41+
sync.into(project.layout.buildDirectory.dir('generated-antora-resources/modules/ROOT/assets/attachments/api'))
42+
sync.from(project.provider({ project.tasks.api.outputs })) { copy ->
43+
copy.into('java')
44+
}
45+
sync.from(project.tasks.named("dokkaGeneratePublicationHtml")) { copy ->
46+
copy.into('kotlin')
47+
}
2848
}
2949

3050
project.tasks.register("generateAntoraResources") {
@@ -53,4 +73,16 @@ public class DocsPlugin implements Plugin<Project> {
5373
}
5474
project.tasks.assemble.dependsOn docs
5575
}
76+
77+
void configureDokka(Project project) {
78+
project.extensions.configure("dokka") { dokka ->
79+
dokka.dokkaSourceSets.configureEach { spec ->
80+
spec.suppressedFiles.from(project.fileTree("src/main/java"))
81+
spec.externalDocumentationLinks.register("javadoc") {
82+
it.url.set(new URI("https://docs.spring.io/${Utils.getProjectName(project)}/reference/${project.rootProject.version}/api/java/"))
83+
it.packageListUrl.set(project.layout.buildDirectory.file("api/element-list").get().asFile.toURI())
84+
}
85+
}
86+
}
87+
}
5688
}

docs/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
** xref:migration/reactive.adoc[Reactive]
1212
* xref:getting-spring-security.adoc[Getting Spring Security]
1313
* xref:attachment$api/java/index.html[Javadoc]
14+
* xref:attachment$api/kotlin/index.html[KDoc]
1415
* xref:features/index.adoc[Features]
1516
** xref:features/authentication/index.adoc[Authentication]
1617
*** xref:features/authentication/password-storage.adoc[Password Storage]

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ org-apache-maven-resolver = "1.9.27"
88
org-aspectj = "1.9.25.1"
99
org-bouncycastle = "1.83"
1010
org-eclipse-jetty = "11.0.26"
11+
org-jetbrains-dokka = "2.1.0"
1112
org-jetbrains-kotlin = "2.3.20"
1213
org-jetbrains-kotlinx = "1.10.2"
1314
org-mockito = "5.23.0"
@@ -67,6 +68,7 @@ org-eclipse-jetty-jetty-servlet = { module = "org.eclipse.jetty:jetty-servlet",
6768
org-hamcrest = "org.hamcrest:hamcrest:2.2"
6869
org-hibernate-orm-hibernate-core = "org.hibernate.orm:hibernate-core:7.3.0.Final"
6970
org-hsqldb = "org.hsqldb:hsqldb:2.7.4"
71+
org-jetbrains-dokka-dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "org-jetbrains-dokka" }
7072
org-jetbrains-kotlin-kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "org-jetbrains-kotlin" }
7173
org-jetbrains-kotlin-kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "org-jetbrains-kotlin" }
7274
org-jetbrains-kotlinx-kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "org-jetbrains-kotlinx" }

0 commit comments

Comments
 (0)