Skip to content

Commit 916ef91

Browse files
authored
Upgrade Dokka to 2.2.0 and migrate to Gradle plugin v2 DSL (#3731)
Upgrades Dokka from 1.8.10 to 2.2.0 and migrates to the v2 Gradle plugin DSL. Upgrades Kotlin version just for the Dokka plugin (required by v2). This is a first step towards AGP 9 since Dokka 1.x was blocking that. ## Changes - Dokka bumped to 2.2.0 - Config adapted to use the `dokka` extension and preserve existng contents - CI docs job now runs `./gradlew :dokkaGenerate` rather than `dokkaHtmlMultiModule`. - dokka-hide-internal: Dokka 2.2's K2 analysis needs a newer Kotlin stdlib at test runtime; added as testRuntimeOnly, version tracked in the catalog (dokkaAnalysisKotlin). - Fixed a pre-existing broken source link base (public/src/main/java to purchases/src/main/java). ## Verification The docs CI job only runs on release tags, so verified locally: - :dokkaGenerate output diffed against a Dokka 1.8.10 build from the merge base: identical module layout and deep-link URLs; CEC and paywalls.components suppressions, README landing page, and hide-internal filtering all intact. Only additions are enum entries pages and a ui-kit static assets dir from the new Dokka HTML format. - dokka-hide-internal tests pass against the 2.2.0 engine. Ref: #2618 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes the release docs pipeline and a major Dokka upgrade; SDK runtime is unaffected, but incomplete v2 config or test classpath quirks could break CI doc generation or `dokka-hide-internal` tests. > > **Overview** > **Dokka** is upgraded from **1.8.10** to **2.2.0** and doc generation moves to the **Gradle plugin v2** model (`dokka { }` DSL, `:dokkaGenerate` instead of `dokkaHtmlMultiModule` / `dokkaHtmlPartial`). > > The **root** build applies the `base` plugin, drops the custom `clean` task and the old `DokkaMultiModuleTask` hook, and instead auto-registers every subproject that applies Dokka into the root `dokka` dependency graph. HTML output stays under `docs/${VERSION_NAME}` with `README.md` included. **CI** `docs-deploy` runs `./gradlew :dokkaGenerate`. > > **`purchases`** and **`ui/revenuecatui`** use top-level `dokka { dokkaSourceSets { ... } }` with v2 APIs (`dependentSourceSets`, `externalDocumentationLinks.register`, `remoteUrl(...)`). **`purchases`** extracts shared source-set settings into `configureDocumentedSourceSet()` and fixes the `src/main/java` GitHub source link path. > > **`dokka-hide-internal`** adds `analysis-kotlin-symbols` and Kotlin **2.2.0** stdlib as **testRuntimeOnly** so Dokka 2.2 K2 analysis works while the repo still compiles on Kotlin **2.0.21**. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c8b1585. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 750add6 commit 916ef91

6 files changed

Lines changed: 47 additions & 77 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ jobs:
375375
- android/restore_build_cache
376376
- run:
377377
name: Dokka
378-
command: ./gradlew dokkaHtmlMultiModule
378+
command: ./gradlew :dokkaGenerate
379379
- android/save_gradle_cache
380380
- android/save_build_cache
381381
- run:

build.gradle.kts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
base
23
alias(libs.plugins.mavenPublish) apply false
34
alias(libs.plugins.android.application) apply false
45
alias(libs.plugins.android.library) apply false
@@ -27,8 +28,20 @@ dependencies {
2728
detektPlugins(project(":detekt-rules"))
2829
}
2930

30-
tasks.register<Delete>("clean") {
31-
delete(rootProject.layout.buildDirectory)
31+
// Aggregate docs from every module that applies the Dokka plugin (currently done by revenuecat-public-library),
32+
// so new library modules are documented without having to remember to list them here.
33+
val dokkaPluginId = libs.plugins.dokka.get().pluginId
34+
subprojects {
35+
plugins.withId(dokkaPluginId) {
36+
rootProject.dependencies.add("dokka", project)
37+
}
38+
}
39+
40+
dokka {
41+
dokkaPublications.html {
42+
outputDirectory.set(file("docs/${project.property("VERSION_NAME")}"))
43+
includes.from("README.md")
44+
}
3245
}
3346

3447
tasks.register<io.gitlab.arturbosch.detekt.Detekt>("detektAll") {
@@ -70,8 +83,3 @@ tasks.register<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>("detektAllB
7083
"**/testCustomEntitlementComputation/**/*.kt",
7184
)
7285
}
73-
74-
tasks.named<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("dokkaHtmlMultiModule") {
75-
outputDirectory.set(file("docs/${project.property("VERSION_NAME")}"))
76-
includes.from("README.md")
77-
}

dokka-hide-internal/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ dependencies {
2121
testImplementation(libs.kotlin.test)
2222
testImplementation(libs.dokka.testApi)
2323
testImplementation(libs.dokka.baseTestUtils)
24+
testRuntimeOnly(libs.dokka.analysisKotlinSymbols)
25+
// Dokka 2.2 K2 analysis needs Kotlin stdlib APIs newer than the repo's 2.0.21 (test runtime only).
26+
testRuntimeOnly("org.jetbrains.kotlin:kotlin-stdlib:${libs.versions.dokkaAnalysisKotlin.get()}")
2427
}

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ datastorePreference = "1.0.0"
3131
dependencyGraph = "0.9"
3232
detekt = "1.23.8"
3333
detektRulesCompose = "0.4.10"
34-
dokka = "1.8.10"
34+
dokka = "2.2.0"
35+
dokkaAnalysisKotlin = "2.2.0"
3536
emergeGradlePlugin = "4.4.0"
3637
emergeSnapshots = "1.5.0"
3738
espresso = "3.6.1"
@@ -144,6 +145,7 @@ detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting",
144145
detekt-libraries = { module = "io.gitlab.arturbosch.detekt:detekt-rules-libraries", version.ref = "detekt"}
145146
detekt-test = { module = "io.gitlab.arturbosch.detekt:detekt-test", version.ref = "detekt" }
146147

148+
dokka-analysisKotlinSymbols = { module = "org.jetbrains.dokka:analysis-kotlin-symbols", version.ref = "dokka" }
147149
dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka" }
148150
dokka-baseTestUtils = { module = "org.jetbrains.dokka:dokka-base-test-utils", version.ref = "dokka" }
149151
dokka-core = { module = "org.jetbrains.dokka:dokka-core", version.ref = "dokka" }

purchases/build.gradle.kts

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceSetSpec
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
23
import java.io.FileInputStream
34
import java.util.Properties
@@ -237,44 +238,33 @@ dependencies {
237238
testImplementation(kotlin("test"))
238239
}
239240

240-
tasks.dokkaHtmlPartial.configure {
241+
fun DokkaSourceSetSpec.configureDocumentedSourceSet() {
242+
reportUndocumented.set(true)
243+
skipDeprecated.set(true)
244+
externalDocumentationLinks.register("android") {
245+
url("https://developer.android.com/reference/")
246+
}
247+
}
248+
249+
dokka {
241250
dokkaSourceSets {
242251
named("customEntitlementComputation") {
243252
suppress.set(true)
244253
}
245254
named("defaults") {
246-
dependsOn("main")
247-
reportUndocumented.set(true)
248-
includeNonPublic.set(false)
249-
skipDeprecated.set(true)
250-
externalDocumentationLink {
251-
url.set(
252-
uri("https://developer.android.com/reference/package-list").toURL(),
253-
)
254-
}
255+
dependentSourceSets.addLater(dokkaSourceSets.named("main").flatMap { it.sourceSetId })
256+
configureDocumentedSourceSet()
257+
}
258+
named("main") {
259+
configureDocumentedSourceSet()
255260
sourceLink {
256-
localDirectory.set(
257-
file("src/main/kotlin"),
258-
)
259-
remoteUrl.set(
260-
uri("https://github.com/revenuecat/purchases-android/blob/main/purchases/src/main/kotlin").toURL(),
261-
)
262-
remoteLineSuffix.set("#L")
261+
localDirectory.set(file("src/main/kotlin"))
262+
remoteUrl("https://github.com/revenuecat/purchases-android/blob/main/purchases/src/main/kotlin")
263263
}
264264
sourceLink {
265-
localDirectory.set(
266-
file("src/main/java"),
267-
)
268-
remoteUrl.set(
269-
uri("https://github.com/revenuecat/purchases-android/blob/main/public/src/main/java").toURL(),
270-
)
271-
remoteLineSuffix.set("#L")
265+
localDirectory.set(file("src/main/java"))
266+
remoteUrl("https://github.com/revenuecat/purchases-android/blob/main/purchases/src/main/java")
272267
}
273-
}
274-
named("main") {
275-
reportUndocumented.set(true)
276-
includeNonPublic.set(false)
277-
skipDeprecated.set(true)
278268

279269
// This package exclusively contains symbols annotated with @InternalRevenueCatAPI, for which no
280270
// documentation is generated due to our dokka-hide-internal plugin. However, by default Dokka still
@@ -283,29 +273,6 @@ tasks.dokkaHtmlPartial.configure {
283273
matchingRegex.set("com\\.revenuecat\\.purchases\\.paywalls\\.components.*")
284274
suppress.set(true)
285275
}
286-
externalDocumentationLink {
287-
url.set(
288-
uri("https://developer.android.com/reference/package-list").toURL(),
289-
)
290-
}
291-
sourceLink {
292-
localDirectory.set(
293-
file("src/main/kotlin"),
294-
)
295-
remoteUrl.set(
296-
uri(
297-
"https://github.com/revenuecat/purchases-android/blob/main/purchases/src/main/kotlin",
298-
).toURL(),
299-
)
300-
remoteLineSuffix.set("#L")
301-
}
302-
sourceLink {
303-
localDirectory.set(file("src/main/java"))
304-
remoteUrl.set(
305-
uri("https://github.com/revenuecat/purchases-android/blob/main/public/src/main/java").toURL(),
306-
)
307-
remoteLineSuffix.set("#L")
308-
}
309276
}
310277
}
311278
}

ui/revenuecatui/build.gradle.kts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,31 +135,21 @@ dependencies {
135135
baselineProfile(project(":baselineprofile"))
136136
}
137137

138-
tasks.dokkaHtmlPartial.configure {
138+
dokka {
139139
dokkaSourceSets {
140140
named("defaults") {
141-
dependsOn("main")
141+
dependentSourceSets.addLater(dokkaSourceSets.named("main").flatMap { it.sourceSetId })
142142
}
143143
named("main") {
144144
reportUndocumented.set(true)
145-
includeNonPublic.set(false)
146145
skipDeprecated.set(true)
147146

148-
externalDocumentationLink {
149-
url.set(
150-
uri("https://developer.android.com/reference/package-list").toURL(),
151-
)
147+
externalDocumentationLinks.register("android") {
148+
url("https://developer.android.com/reference/")
152149
}
153150
sourceLink {
154-
localDirectory.set(
155-
file("src/main/kotlin"),
156-
)
157-
remoteUrl.set(
158-
uri(
159-
"https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/src/main/kotlin",
160-
).toURL(),
161-
)
162-
remoteLineSuffix.set("#L")
151+
localDirectory.set(file("src/main/kotlin"))
152+
remoteUrl("https://github.com/revenuecat/purchases-android/blob/main/ui/revenuecatui/src/main/kotlin")
163153
}
164154
}
165155
}

0 commit comments

Comments
 (0)