Skip to content

misc: upgrade to Dokka 2.0.0 #1597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fb53db86-ba89-44ae-86e3-1c85abb9c217.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "fb53db86-ba89-44ae-86e3-1c85abb9c217",
"type": "misc",
"description": "Upgrade to Dokka 2.0.0"
}
1 change: 1 addition & 0 deletions .github/workflows/release-readiness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
repository: 'smithy-lang/smithy-kotlin'

- name: Check for smithy-kotlin unreleased changes
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ready-for-release') }}
run: |
echo "aws-sdk-kotlin branch: $GITHUB_HEAD_REF"

Expand Down
11 changes: 6 additions & 5 deletions aws-runtime/aws-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import aws.sdk.kotlin.gradle.codegen.dsl.generateSmithyProjections
import aws.sdk.kotlin.gradle.codegen.dsl.smithyKotlinPlugin
import aws.sdk.kotlin.gradle.codegen.smithyKotlinProjectionSrcDir
import org.jetbrains.dokka.gradle.DokkaTaskPartial

plugins {
alias(libs.plugins.aws.kotlin.repo.tools.smithybuild)
Expand Down Expand Up @@ -85,7 +84,6 @@ smithyBuild {
val basePackage = "aws.sdk.kotlin.runtime.auth.credentials.internal"

projections {

// generate an sts client
create("sts-credentials-provider") {
imports = listOf(
Expand Down Expand Up @@ -243,9 +241,12 @@ smithyBuild.projections.all {
}
}

// suppress internal generated clients
tasks.named<DokkaTaskPartial>("dokkaHtmlPartial") {
dependsOn(tasks.generateSmithyProjections)
// Suppress internally-generated clients
dokka {
tasks.dokkaGenerateModuleHtml {
dependsOn(tasks.generateSmithyProjections)
}

dokkaSourceSets.configureEach {
perPackageOption {
matchingRegex.set(""".*\.internal.*""")
Expand Down
15 changes: 9 additions & 6 deletions aws-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
description = "AWS client runtime support for generated service clients"

plugins {
alias(libs.plugins.dokka)
`dokka-convention`
alias(libs.plugins.kotlinx.binary.compatibility.validator)
alias(libs.plugins.aws.kotlin.repo.tools.kmp) apply false
jacoco
Expand All @@ -28,7 +28,6 @@ subprojects {

apply {
plugin("org.jetbrains.kotlin.multiplatform")
plugin("org.jetbrains.dokka")
plugin(libraries.plugins.aws.kotlin.repo.tools.kmp.get().pluginId)
}

Expand Down Expand Up @@ -61,10 +60,6 @@ subprojects {
listOf("kotlin.RequiresOptIn").forEach { languageSettings.optIn(it) }
}

dependencies {
dokkaPlugin(project(":dokka-aws"))
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
Expand All @@ -77,3 +72,11 @@ subprojects {
}
}
}

// Configure Dokka for subprojects
dependencies {
subprojects.forEach {
it.plugins.apply("dokka-convention") // Apply the Dokka conventions plugin to the subproject
dokka(project(it.path)) // Aggregate the subprojects' generated documentation
}
}
92 changes: 16 additions & 76 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import aws.sdk.kotlin.gradle.dsl.configureLinting
import aws.sdk.kotlin.gradle.dsl.configureNexus
import aws.sdk.kotlin.gradle.util.typedProp
import java.net.URL

buildscript {
// NOTE: buildscript classpath for the root project is the parent classloader for the subprojects, we
Expand All @@ -18,10 +17,10 @@ buildscript {
}

plugins {
alias(libs.plugins.dokka)
`dokka-convention`
// ensure the correct version of KGP ends up on our buildscript classpath
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.jvm) apply false
id(libs.plugins.kotlin.multiplatform.get().pluginId) apply false
id(libs.plugins.kotlin.jvm.get().pluginId) apply false
alias(libs.plugins.aws.kotlin.repo.tools.artifactsizemetrics)
}

Expand All @@ -39,67 +38,9 @@ val testJavaVersion = typedProp<String>("test.java.version")?.let {
}

allprojects {
tasks.withType<org.jetbrains.dokka.gradle.AbstractDokkaTask>().configureEach {
val sdkVersion: String by project
moduleVersion.set(sdkVersion)

val year = java.time.LocalDate.now().year
val pluginConfigMap = mapOf(
"org.jetbrains.dokka.base.DokkaBase" to """
{
"customStyleSheets": [
"${rootProject.file("docs/dokka-presets/css/logo-styles.css")}",
"${rootProject.file("docs/dokka-presets/css/aws-styles.css")}"
],
"customAssets": [
"${rootProject.file("docs/dokka-presets/assets/logo-icon.svg")}",
"${rootProject.file("docs/dokka-presets/assets/aws_logo_white_59x35.png")}",
"${rootProject.file("docs/dokka-presets/scripts/accessibility.js")}"
],
"footerMessage": "© $year, Amazon Web Services, Inc. or its affiliates. All rights reserved.",
"separateInheritedMembers" : true,
"templatesDir": "${rootProject.file("docs/dokka-presets/templates")}"
}
""",
)
pluginsMapConfiguration.set(pluginConfigMap)
}

tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {
// each module can include their own top-level module documentation
// see https://kotlinlang.org/docs/dokka-module-and-package-docs.html
if (project.file("API.md").exists()) {
dokkaSourceSets.configureEach {
includes.from(project.file("API.md"))
}
}

dokkaSourceSets.configureEach {
samples.from(project.file("samples").path, project.file("generated-src/samples").path)
}

val smithyKotlinPackageListUrl: String? by project
val smithyKotlinDocBaseUrl: String? by project

// Configure Dokka to link to smithy-kotlin types if specified in properties
// These optional properties are supplied api the api docs build job but are unneeded otherwise
smithyKotlinDocBaseUrl.takeUnless { it.isNullOrEmpty() }?.let { docBaseUrl ->
val expandedDocBaseUrl = docBaseUrl.replace("\$smithyKotlinRuntimeVersion", libs.versions.smithy.kotlin.runtime.version.get())
dokkaSourceSets.configureEach {
externalDocumentationLink {
url.set(URL(expandedDocBaseUrl))

smithyKotlinPackageListUrl
.takeUnless { it.isNullOrEmpty() }
?.let { packageListUrl.set(URL(it)) }
}
}
}
}

if (rootProject.typedProp<Boolean>("kotlinWarningsAsErrors") == true) {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.allWarningsAsErrors = true
compilerOptions.allWarningsAsErrors = true
}
}

Expand All @@ -118,26 +59,24 @@ allprojects {
tasks.register<DependencyReportTask>("allDeps") { }
}

project.afterEvaluate {
// configure the root multimodule docs
tasks.dokkaHtmlMultiModule.configure {
moduleName.set("AWS SDK for Kotlin")

// Output subprojects' docs to <docs-base>/project-name/* instead of <docs-base>/path/to/project-name/*
// This is especially important for inter-repo linking (e.g., via externalDocumentationLink) because the
// package-list doesn't contain enough project path information to indicate where modules' documentation are
// located.
fileLayout.set { parent, child ->
parent.outputDirectory.dir(child.moduleName)
}
// Configure root module's documentation
dokka {
moduleName.set("AWS SDK for Kotlin")

dokkaPublications.html {
includes.from(
// NOTE: these get concatenated
rootProject.file("docs/dokka-presets/README.md"),
)
}
}

// Aggregate subprojects' documentation
dependencies {
dokka(project(":aws-runtime"))
dokka(project(":services"))
dokka(project(":hll"))
}

// Publishing
configureNexus()

Expand All @@ -148,6 +87,7 @@ val lintPaths = listOf(
"!**/generated/ksp/**",
"!**/kspCaches/**",
"!**/smithyprojections/**",
"!**/build/**",
)

configureLinting(lintPaths)
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
plugins {
alias(libs.plugins.kotlin.jvm)
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation(libs.dokka.gradle.plugin)
implementation(libs.kotlin.gradle.plugin)
}
2 changes: 2 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rootProject.name = "buildSrc"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
Expand Down
60 changes: 60 additions & 0 deletions buildSrc/src/main/kotlin/dokka-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import kotlin.text.set

plugins {
id("org.jetbrains.dokka")
}

dokka {
val sdkVersion: String by project
moduleVersion.set(sdkVersion)

dokkaGeneratorIsolation = ProcessIsolation {
maxHeapSize = "4g"
}

pluginsConfiguration.html {
customStyleSheets.from(
rootProject.file("docs/dokka-presets/css/aws-styles.css"),
)

customAssets.from(
rootProject.file("docs/dokka-presets/assets/logo-icon.svg"),
rootProject.file("docs/dokka-presets/scripts/accessibility.js"),
)

templatesDir.set(rootProject.file("docs/dokka-presets/templates"))

footerMessage.set("© ${java.time.LocalDate.now().year}, Amazon Web Services, Inc. or its affiliates. All rights reserved.")
separateInheritedMembers.set(true)
}

// each module can include their own top-level module documentation
// see https://kotlinlang.org/docs/kotlin-doc.html#module-and-package-documentation
if (project.file("API.md").exists()) {
dokkaSourceSets.configureEach {
includes.from(project.file("API.md"))
}
}

dokkaSourceSets.configureEach {
// Only configure samples on `commonMain`.
// Fixes compiler warnings: "Source sets 'common' and 'desktop' have the common sample roots. In Dokka K2 it will be an error."
if (name == "commonMain") {
samples.from(project.file("samples").path, project.file("generated-src/samples").path)
}
}

// Configure Dokka to link to smithy-kotlin types
dokkaSourceSets.configureEach {
externalDocumentationLinks {
create("smithy-kotlin") {
val smithyKotlinRuntimeVersion = versionCatalogs.named("libs").findVersion("smithy-kotlin-runtime-version").get()
url("https://sdk.amazonaws.com/kotlin/api/smithy-kotlin/api/$smithyKotlinRuntimeVersion")
}
}
}
}

dependencies {
dokkaPlugin(project(":dokka-aws"))
}
2 changes: 1 addition & 1 deletion codegen/aws-sdk-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
alias(libs.plugins.kotlin.jvm)
id(libs.plugins.kotlin.jvm.get().pluginId)
jacoco
}

Expand Down
Binary file removed docs/dokka-presets/assets/aws_logo_white_59x35.png
Binary file not shown.
51 changes: 37 additions & 14 deletions docs/dokka-presets/assets/logo-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading