Include Kotlin API documentation in the documentation site

Closes gh-40692
This commit is contained in:
Andy Wilkinson 2024-05-10 14:53:48 +01:00
parent 772e4ca78d
commit 53e1c7ed7d
9 changed files with 42 additions and 6 deletions

View File

@ -41,6 +41,7 @@ dependencies {
implementation(platform("org.springframework:spring-framework-bom:${versions.springFramework}"))
implementation("com.diffplug.gradle:goomph:3.37.2")
implementation("dev.adamko.dokkatoo:dokkatoo-plugin:2.3.1")
implementation("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")
implementation("com.github.node-gradle:gradle-node-plugin:3.5.1")
implementation("com.gradle:develocity-gradle-plugin:3.17.2")

View File

@ -261,8 +261,9 @@ class JavaConventions {
configuration.setCanBeResolved(false);
});
configurations
.matching((configuration) -> configuration.getName().endsWith("Classpath")
.matching((configuration) -> (configuration.getName().endsWith("Classpath")
|| JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME.equals(configuration.getName()))
&& (!configuration.getName().contains("dokkatoo")))
.all((configuration) -> configuration.extendsFrom(dependencyManagement));
Dependency springBootParent = project.getDependencies()
.enforcedPlatform(project.getDependencies()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,10 @@ package org.springframework.boot.build;
import java.util.ArrayList;
import java.util.List;
import dev.adamko.dokkatoo.DokkatooExtension;
import dev.adamko.dokkatoo.formats.DokkatooHtmlPlugin;
import org.gradle.api.Project;
import org.gradle.api.tasks.SourceSet;
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions;
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
@ -44,9 +47,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
class KotlinConventions {
void apply(Project project) {
project.getPlugins()
.withId("org.jetbrains.kotlin.jvm",
(plugin) -> project.getTasks().withType(KotlinCompile.class, this::configure));
project.getPlugins().withId("org.jetbrains.kotlin.jvm", (plugin) -> {
project.getTasks().withType(KotlinCompile.class, this::configure);
configureDokkatoo(project);
});
}
private void configure(KotlinCompile compile) {
@ -60,4 +64,12 @@ class KotlinConventions {
compile.getKotlinOptions().setFreeCompilerArgs(freeCompilerArgs);
}
private void configureDokkatoo(Project project) {
project.getPlugins().apply(DokkatooHtmlPlugin.class);
DokkatooExtension dokkatoo = project.getExtensions().getByType(DokkatooExtension.class);
dokkatoo.getDokkatooSourceSets()
.named(SourceSet.MAIN_SOURCE_SET_NAME)
.configure((spec) -> spec.getSourceRoots().setFrom(project.file("src/main/kotlin")));
}
}

View File

@ -1,6 +1,5 @@
plugins {
id "java-library"
id "org.jetbrains.kotlin.jvm"
id "org.springframework.boot.auto-configuration"
id "org.springframework.boot.configuration-properties"
id "org.springframework.boot.conventions"

View File

@ -54,6 +54,9 @@ dependencies {
configurationProperties(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-testcontainers", configuration: "configurationPropertiesMetadata"))
dokkatoo(project(path: ":spring-boot-project:spring-boot"))
dokkatoo(project(path: ":spring-boot-project:spring-boot-test"))
implementation(project(path: ":spring-boot-project:spring-boot-actuator"))
implementation(project(path: ":spring-boot-project:spring-boot-actuator-autoconfigure"))
implementation(project(path: ":spring-boot-project:spring-boot-autoconfigure"))
@ -183,6 +186,10 @@ dependencies {
testSlices(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "testSliceMetadata"))
}
dokkatoo {
moduleName.set("Spring Boot Kotlin API")
}
task aggregatedJavadoc(type: Javadoc) {
dependsOn dependencyVersions
project.rootProject.gradle.projectsEvaluated {
@ -344,6 +351,9 @@ def antoraApiCatalogContent = tasks.register("antoraApiCatalogContent", Zip) {
from(aggregatedJavadoc) {
into "java"
}
from(tasks.named("dokkatooGeneratePublicationHtml")) {
into "kotlin"
}
}
def copyAntoraContentDependencies = tasks.register("copyAntoraContentDependencies", Copy) {
@ -366,6 +376,12 @@ gradle.projectsEvaluated {
}
}
dokkatoo {
dokkatooPublications.configureEach {
includes.from("src/docs/dokkatoo/dokka-overview.md")
}
}
publishing {
publications {
getByName("maven") {

View File

@ -28,3 +28,5 @@ ext:
attributes: { external: true}
- path: [ "Java APIs", "Gradle Plugin" ]
attributes: { external: true }
- path: [ "Kotlin APIs", "Spring Boot" ]
attributes: { external: true }

View File

@ -0,0 +1,2 @@
* Kotlin APIs
** xref:api:kotlin/index.html[Spring Boot]

View File

@ -6,5 +6,6 @@ include::build-tool-plugin:partial$nav-build-tool-plugin.adoc[]
include::cli:partial$nav-cli.adoc[]
include::api:partial$nav-rest-api.adoc[]
include::api:partial$nav-java-api.adoc[]
include::api:partial$nav-kotlin-api.adoc[]
include::specification:partial$nav-specification.adoc[]
include::appendix:partial$nav-appendix.adoc[]

View File

@ -0,0 +1,2 @@
# All Modules
_See also the <a href="../java/index.html" target="_blank">Java API documentation (Javadoc)</a>._