Skip to content

Commit 10c7b9d

Browse files
authored
Migrate to DGPv2 (#3005)
1 parent 16306f4 commit 10c7b9d

File tree

8 files changed

+157
-164
lines changed

8 files changed

+157
-164
lines changed

build.gradle.kts

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ apiValidation {
7878

7979
knit {
8080
siteRoot = "https://kotlinlang.org/api/kotlinx.serialization"
81-
moduleDocs = "build/dokka/htmlMultiModule"
81+
moduleDocs = "build/dokka-module/html/module"
82+
dokkaMultiModuleRoot = "build/dokka/html/"
8283
}
8384

8485
// Build API docs for all modules with dokka before running Knit
8586
tasks.named("knitPrepare") {
86-
dependsOn("dokka")
87+
dependsOn("dokkaGenerate")
8788
}
8889

8990

@@ -135,17 +136,14 @@ subprojects {
135136
}
136137
}
137138

138-
// Knit relies on Dokka task and it's pretty convenient
139-
tasks.register("dokka") {
140-
dependsOn("dokkaHtmlMultiModule")
141-
}
142-
143-
tasks.withType<DokkaMultiModuleTask>().named("dokkaHtmlMultiModule") {
144-
pluginsMapConfiguration.put("org.jetbrains.dokka.base.DokkaBase", """{ "templatesDir": "${projectDir.toString().replace("\\", "/")}/dokka-templates" }""")
145-
}
146-
139+
// apply conventions to root module and setup dependencies for aggregation
140+
apply(plugin = "dokka-conventions")
147141
dependencies {
148-
dokkaPlugin(libs.dokka.pathsaver)
142+
subprojects.forEach {
143+
if (it.name in documentedSubprojects) {
144+
dokka(it)
145+
}
146+
}
149147
}
150148

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

160158
// == projects lists and flags ==
161159
// getters are required because of variable lazy initialization in Gradle
162-
val unpublishedProjects get() = setOf(
163-
"benchmark",
164-
"guide",
165-
"kotlinx-serialization-json-tests",
166-
"proto-test-model",
167-
)
160+
val unpublishedProjects
161+
get() = setOf(
162+
"benchmark",
163+
"guide",
164+
"kotlinx-serialization-json-tests",
165+
"proto-test-model",
166+
)
168167
val excludedFromBomProjects get() = unpublishedProjects + "kotlinx-serialization-bom"
169168

170-
val documentedSubprojects get() = setOf("kotlinx-serialization-core",
171-
"kotlinx-serialization-json",
172-
"kotlinx-serialization-json-okio",
173-
"kotlinx-serialization-json-io",
174-
"kotlinx-serialization-cbor",
175-
"kotlinx-serialization-properties",
176-
"kotlinx-serialization-hocon",
177-
"kotlinx-serialization-protobuf")
169+
val documentedSubprojects
170+
get() = setOf(
171+
"kotlinx-serialization-core",
172+
"kotlinx-serialization-json",
173+
"kotlinx-serialization-json-okio",
174+
"kotlinx-serialization-json-io",
175+
"kotlinx-serialization-cbor",
176+
"kotlinx-serialization-properties",
177+
"kotlinx-serialization-hocon",
178+
"kotlinx-serialization-protobuf"
179+
)
Lines changed: 16 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
/*
2-
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3-
*/
4-
5-
import org.jetbrains.dokka.gradle.*
6-
import java.net.URI
7-
81
/*
92
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
103
*/
@@ -18,62 +11,24 @@ dependencies {
1811
dokkaPlugin(provider { extens.getByType<VersionCatalogsExtension>().named("libs").findLibrary("dokka.pathsaver").get().get() })
1912
}
2013

21-
tasks.withType<DokkaTaskPartial>().named("dokkaHtmlPartial") {
22-
outputDirectory.set(file("build/dokka"))
23-
24-
25-
pluginsMapConfiguration.put("org.jetbrains.dokka.base.DokkaBase", """{ "templatesDir": "${rootDir.resolve("dokka-templates").canonicalPath.replace('\\', '/')}" }""")
26-
27-
dokkaSourceSets {
28-
configureEach {
29-
includes.from(rootDir.resolve("dokka/moduledoc.md").path)
30-
31-
perPackageOption {
32-
matchingRegex.set("kotlinx\\.serialization(\$|\\.).*")
33-
reportUndocumented.set(true)
34-
skipDeprecated.set(true)
35-
}
36-
37-
// Internal API
38-
perPackageOption {
39-
matchingRegex.set("kotlinx\\.serialization.internal(\$|\\.).*")
40-
suppress.set(true)
41-
}
42-
43-
// Internal JSON API
44-
perPackageOption {
45-
matchingRegex.set("kotlinx\\.serialization.json.internal(\$|\\.).*")
46-
suppress.set(true)
47-
reportUndocumented.set(false)
48-
}
49-
50-
// Workaround for typealias
51-
perPackageOption {
52-
matchingRegex.set("kotlinx\\.serialization.protobuf.internal(\$|\\.).*")
53-
suppress.set(true)
54-
reportUndocumented.set(false)
55-
}
56-
57-
// Deprecated migrations
58-
perPackageOption {
59-
matchingRegex.set("kotlinx\\.protobuf(\$|\\.).*")
60-
reportUndocumented.set(true)
61-
skipDeprecated.set(true)
62-
}
14+
dokka {
15+
pluginsConfiguration.html {
16+
templatesDir = rootDir.resolve("dokka-templates")
17+
}
6318

64-
// Deprecated migrations
65-
perPackageOption {
66-
matchingRegex.set("org\\.jetbrains\\.kotlinx\\.serialization\\.config(\$|\\.).*")
67-
reportUndocumented.set(false)
68-
skipDeprecated.set(true)
69-
}
19+
dokkaSourceSets.configureEach {
20+
includes.from(rootDir.resolve("dokka/moduledoc.md").path)
21+
reportUndocumented = true
22+
skipDeprecated = true
7023

71-
sourceLink {
72-
localDirectory.set(rootDir)
24+
perPackageOption {
25+
matchingRegex = ".*\\.internal(\\..*)?"
26+
suppress = true
27+
}
7328

74-
remoteUrl.set(URI("https://github.com/Kotlin/kotlinx.serialization/tree/master").toURL())
75-
remoteLineSuffix.set("#L")
76-
}
29+
sourceLink {
30+
localDirectory = rootDir
31+
remoteUrl("https://github.com/Kotlin/kotlinx.serialization/tree/master")
7732
}
7833
}
79-
}
34+
}

formats/json-io/build.gradle.kts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ kotlin {
3333

3434
project.configureJava9ModuleInfo()
3535

36-
tasks.named<DokkaTaskPartial>("dokkaHtmlPartial") {
37-
dokkaSourceSets {
38-
configureEach {
39-
externalDocumentationLink {
40-
url.set(URI("https://kotlin.github.io/kotlinx-io/").toURL())
41-
}
42-
}
36+
dokka.dokkaSourceSets.configureEach {
37+
externalDocumentationLinks.register("kotlinx-io") {
38+
url("https://kotlinlang.org/api/kotlinx-io/")
39+
packageListUrl = file("dokka/kotlinx-io.package-list").toURI()
4340
}
4441
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$dokka.format:html-v1
2+
$dokka.linkExtension:html
3+
4+
module:kotlinx-io-bytestring
5+
kotlinx.io.bytestring
6+
module:kotlinx-io-core
7+
kotlinx.io
8+
kotlinx.io.files
9+
module:kotlinx-io-okio
10+
kotlinx.io.okio

formats/json-okio/build.gradle.kts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,9 @@ kotlin {
3434

3535
project.configureJava9ModuleInfo()
3636

37-
tasks.named<DokkaTaskPartial>("dokkaHtmlPartial") {
38-
dokkaSourceSets {
39-
configureEach {
40-
externalDocumentationLink {
41-
url.set(URI("https://square.github.io/okio/3.x/okio/").toURL())
42-
packageListUrl.set(
43-
file("dokka/okio.package.list").toURI().toURL()
44-
)
45-
}
46-
}
37+
dokka.dokkaSourceSets.configureEach {
38+
externalDocumentationLinks.register("okio") {
39+
url("https://square.github.io/okio/3.x/okio")
40+
packageListUrl = file("dokka/okio.package-list").toURI()
4741
}
4842
}

0 commit comments

Comments
 (0)