Skip to content

Migrate to DGPv2 #3005

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 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 28 additions & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ apiValidation {

knit {
siteRoot = "https://kotlinlang.org/api/kotlinx.serialization"
moduleDocs = "build/dokka/htmlMultiModule"
moduleDocs = "build/dokka-module/html/module"
dokkaMultiModuleRoot = "build/dokka/html/"
}

// Build API docs for all modules with dokka before running Knit
tasks.named("knitPrepare") {
dependsOn("dokka")
dependsOn("dokkaGenerate")
}


Expand Down Expand Up @@ -135,17 +136,14 @@ subprojects {
}
}

// Knit relies on Dokka task and it's pretty convenient
tasks.register("dokka") {
dependsOn("dokkaHtmlMultiModule")
}

tasks.withType<DokkaMultiModuleTask>().named("dokkaHtmlMultiModule") {
pluginsMapConfiguration.put("org.jetbrains.dokka.base.DokkaBase", """{ "templatesDir": "${projectDir.toString().replace("\\", "/")}/dokka-templates" }""")
}

// apply conventions to root module and setup dependencies for aggregation
apply(plugin = "dokka-conventions")
dependencies {
dokkaPlugin(libs.dokka.pathsaver)
subprojects.forEach {
if (it.name in documentedSubprojects) {
dokka(it)
}
}
}

// == NPM setup ==
Expand All @@ -159,19 +157,23 @@ logger.warn("Project is using Kotlin Gradle plugin version: ${project.getKotlinP

// == projects lists and flags ==
// getters are required because of variable lazy initialization in Gradle
val unpublishedProjects get() = setOf(
"benchmark",
"guide",
"kotlinx-serialization-json-tests",
"proto-test-model",
)
val unpublishedProjects
get() = setOf(
"benchmark",
"guide",
"kotlinx-serialization-json-tests",
"proto-test-model",
)
val excludedFromBomProjects get() = unpublishedProjects + "kotlinx-serialization-bom"

val documentedSubprojects get() = setOf("kotlinx-serialization-core",
"kotlinx-serialization-json",
"kotlinx-serialization-json-okio",
"kotlinx-serialization-json-io",
"kotlinx-serialization-cbor",
"kotlinx-serialization-properties",
"kotlinx-serialization-hocon",
"kotlinx-serialization-protobuf")
val documentedSubprojects
get() = setOf(
"kotlinx-serialization-core",
"kotlinx-serialization-json",
"kotlinx-serialization-json-okio",
"kotlinx-serialization-json-io",
"kotlinx-serialization-cbor",
"kotlinx-serialization-properties",
"kotlinx-serialization-hocon",
"kotlinx-serialization-protobuf"
)
76 changes: 15 additions & 61 deletions buildSrc/src/main/kotlin/dokka-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/*
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.dokka.gradle.*
import java.net.URI

/*
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
Expand All @@ -18,62 +11,23 @@ dependencies {
dokkaPlugin(provider { extens.getByType<VersionCatalogsExtension>().named("libs").findLibrary("dokka.pathsaver").get().get() })
}

tasks.withType<DokkaTaskPartial>().named("dokkaHtmlPartial") {
outputDirectory.set(file("build/dokka"))


pluginsMapConfiguration.put("org.jetbrains.dokka.base.DokkaBase", """{ "templatesDir": "${rootDir.resolve("dokka-templates").canonicalPath.replace('\\', '/')}" }""")

dokkaSourceSets {
configureEach {
includes.from(rootDir.resolve("dokka/moduledoc.md").path)

perPackageOption {
matchingRegex.set("kotlinx\\.serialization(\$|\\.).*")
reportUndocumented.set(true)
skipDeprecated.set(true)
}

// Internal API
perPackageOption {
matchingRegex.set("kotlinx\\.serialization.internal(\$|\\.).*")
suppress.set(true)
}

// Internal JSON API
perPackageOption {
matchingRegex.set("kotlinx\\.serialization.json.internal(\$|\\.).*")
suppress.set(true)
reportUndocumented.set(false)
}

// Workaround for typealias
perPackageOption {
matchingRegex.set("kotlinx\\.serialization.protobuf.internal(\$|\\.).*")
suppress.set(true)
reportUndocumented.set(false)
}

// Deprecated migrations
perPackageOption {
matchingRegex.set("kotlinx\\.protobuf(\$|\\.).*")
reportUndocumented.set(true)
skipDeprecated.set(true)
}
dokka {
pluginsConfiguration.html {
templatesDir = rootDir.resolve("dokka-templates")
}

// Deprecated migrations
perPackageOption {
matchingRegex.set("org\\.jetbrains\\.kotlinx\\.serialization\\.config(\$|\\.).*")
reportUndocumented.set(false)
skipDeprecated.set(true)
}
dokkaSourceSets.configureEach {
includes.from(rootDir.resolve("dokka/moduledoc.md").path)
reportUndocumented = true

sourceLink {
localDirectory.set(rootDir)
perPackageOption {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, there were multiple perPackageOption - most of them are obsolete or separate configurations for internal package. So, obsolete were removed and internal are handled by one regex now

matchingRegex = ".*\\.internal(\\..*)?"
suppress = true
}

remoteUrl.set(URI("https://github.com/Kotlin/kotlinx.serialization/tree/master").toURL())
remoteLineSuffix.set("#L")
}
sourceLink {
localDirectory = rootDir
remoteUrl("https://github.com/Kotlin/kotlinx.serialization/tree/master")
}
}
}
}
10 changes: 3 additions & 7 deletions formats/json-io/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ kotlin {

project.configureJava9ModuleInfo()

tasks.named<DokkaTaskPartial>("dokkaHtmlPartial") {
dokkaSourceSets {
configureEach {
externalDocumentationLink {
url.set(URI("https://kotlin.github.io/kotlinx-io/").toURL())
}
}
dokka.dokkaSourceSets.configureEach {
externalDocumentationLinks.register("kotlinx-io") {
url("https://kotlinlang.org/api/kotlinx-io/")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JIC: old URL is not accessible anymore

}
}
14 changes: 4 additions & 10 deletions formats/json-okio/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,9 @@ kotlin {

project.configureJava9ModuleInfo()

tasks.named<DokkaTaskPartial>("dokkaHtmlPartial") {
dokkaSourceSets {
configureEach {
externalDocumentationLink {
url.set(URI("https://square.github.io/okio/3.x/okio/").toURL())
packageListUrl.set(
file("dokka/okio.package.list").toURI().toURL()
)
}
}
dokka.dokkaSourceSets.configureEach {
externalDocumentationLinks.register("okio") {
url("https://square.github.io/okio/3.x/okio")
packageListUrl("https://square.github.io/okio/3.x/okio/okio/package-list")
}
}
Loading