Skip to content

Commit 204d18a

Browse files
authored
fix(build): stabilize dokka v2 generation (#477)
1 parent 2c57870 commit 204d18a

6 files changed

Lines changed: 36 additions & 10 deletions

File tree

.github/instructions/context.instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ description: Use when understanding support-arch architecture, module boundaries
4747

4848
## Documentation Contract
4949

50-
- Dokka is configured centrally in `buildSrc` and the root build script; CI publishes `./gradlew dokkaHtmlMultiModule` output from `dokka-docs` to the `docs` branch.
50+
- Dokka is configured centrally in `buildSrc` and the root build script; CI publishes `./gradlew dokkaGenerate` output from `dokka-docs` to the `docs` branch.
5151
- Dokka has `reportUndocumented = true`, so undocumented public APIs are a quality problem, not an optional cleanup task.
5252
- Packages matching `.internal` are intentionally suppressed from published docs. Do not hide consumer-facing APIs in internal packages.
5353
- When changing public behavior, update KDoc in the same change. Document what the API does, when to use it, and what a consumer must provide or expect.
@@ -57,4 +57,4 @@ description: Use when understanding support-arch architecture, module boundaries
5757
- Put abstractions in the lowest module that can own them without depending on higher-level UI code.
5858
- Preserve the existing legacy paging split unless the task explicitly migrates away from it.
5959
- Prefer shared build logic changes in `buildSrc` over copy-pasting Gradle configuration into individual modules.
60-
- When unsure where code belongs, start from the Dokka module page, inspect neighboring package roots, and confirm the dependency direction before editing.
60+
- When unsure where code belongs, start from the Dokka module page, inspect neighboring package roots, and confirm the dependency direction before editing.

.github/skills/support-arch-build-dependencies/references/build-map.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Use this map to choose the right build file before editing.
55
| Concern | Primary files | Notes |
66
| --- | --- | --- |
77
| Module includes | `settings.gradle.kts` | Declares every published module in the repo |
8-
| Root repositories and multi-module Dokka output | `build.gradle.kts` | `dokkaHtmlMultiModule` writes to `dokka-docs` |
8+
| Root repositories and multi-module Dokka output | `build.gradle.kts` | Root `dokkaGenerate` writes the aggregate Dokka V2 site to `dokka-docs` |
99
| Shared plugin entry point | `buildSrc/.../plugin/CorePlugin.kt` | Applies Android or Kotlin plugin, Dokka, publishing, Spotless, sources, dependencies |
1010
| Shared plugin application | `buildSrc/.../components/ProjectPlugins.kt` | Most modules use `co.anitrend.arch` |
1111
| Shared Android defaults | `buildSrc/.../components/AndroidConfiguration.kt` | SDK levels, view binding, tests, compiler options, toolchain 21 |
@@ -36,4 +36,4 @@ Use this map to choose the right build file before editing.
3636
- Cross-module convention: `buildSrc`.
3737
- One module only: that module's `build.gradle.kts`.
3838
- Documentation generation or publish behavior: Dokka config plus workflow file.
39-
- Annotation surface change: update both `annotation` and `processor` when needed.
39+
- Annotation surface change: update both `annotation` and `processor` when needed.

.github/workflows/gradle-dokka.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ env:
1010
jobs:
1111
gradle-dokka:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
1315
steps:
1416
- uses: actions/checkout@v6
1517
- uses: actions/setup-java@v5
@@ -23,10 +25,10 @@ jobs:
2325
- name: Grant execute permission for gradlew
2426
run: chmod +x gradlew
2527
- name: Generate docs with dokka
26-
run: ./gradlew dokkaGenerate
28+
run: ./gradlew --no-daemon dokkaGenerate
2729

2830
- name: Deploy 🚀
2931
uses: JamesIves/github-pages-deploy-action@v4.8.0
3032
with:
3133
branch: docs # The branch the action should deploy to.
32-
folder: library/build/docs/dokka # The folder the action should deploy.
34+
folder: dokka-docs # The root Dokka V2 publication output.

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
## High-Signal Repo Facts
1010

1111
- Public API docs are generated with Dokka and published to `https://anitrend.github.io/support-arch/`.
12-
- CI publishes docs by running `./gradlew dokkaHtmlMultiModule` on `develop` and deploying `dokka-docs` to the `docs` branch.
12+
- CI publishes docs by running `./gradlew dokkaGenerate` on `develop` and deploying `dokka-docs` to the `docs` branch.
1313
- Most modules use the shared `co.anitrend.arch` Gradle plugin from `buildSrc`.
1414
- Shared Android and Kotlin defaults live in `buildSrc`, not in individual module build files.
1515
- The pinned Java version is `.java-version = 21.0.8` and the shared toolchain is Java 21.
@@ -69,7 +69,7 @@
6969
## Validation
7070

7171
- Formatting: `./gradlew spotlessCheck` or `./gradlew spotlessApply`
72-
- Docs: `./gradlew dokkaHtmlMultiModule`
72+
- Docs: `./gradlew dokkaGenerate`
7373
- Tests: prefer targeted module tests before full-project runs
7474
- If Gradle or Java alignment is unstable, use the existing `jenv-gradle-low-ram` skill
7575

build.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,32 @@ buildscript {
55
}
66
dependencies {
77
classpath(libs.android.gradle.plugin)
8+
classpath(libs.jetbrains.dokka.gradle)
89
classpath(libs.jetbrains.kotlin.gradle)
910
}
1011
}
1112

13+
apply(plugin = "org.jetbrains.dokka")
14+
15+
configure<org.jetbrains.dokka.gradle.DokkaExtension> {
16+
moduleName.set("support-arch")
17+
basePublicationsDirectory.set(layout.projectDirectory.dir("dokka-docs"))
18+
}
19+
20+
dependencies {
21+
add("dokka", project(":analytics"))
22+
add("dokka", project(":core"))
23+
add("dokka", project(":data"))
24+
add("dokka", project(":domain"))
25+
add("dokka", project(":extension"))
26+
add("dokka", project(":paging-legacy"))
27+
add("dokka", project(":recycler"))
28+
add("dokka", project(":recycler-paging-legacy"))
29+
add("dokka", project(":request"))
30+
add("dokka", project(":theme"))
31+
add("dokka", project(":ui"))
32+
}
33+
1234
allprojects {
1335
repositories {
1436
google()

buildSrc/src/main/java/co/anitrend/arch/buildSrc/plugin/components/ProjectDokka.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private fun Project.dependenciesOfProject(): List<Modules.Module> {
5959

6060
internal fun Project.configureDokka() = dokkaExtension().run {
6161
basePublicationsDirectory.set(layout.buildDirectory.dir("docs/dokka"))
62+
val androidPublicationVariant = "release"
6263

6364
// Set module name displayed in the final output
6465
moduleName.set(project.name)
@@ -74,7 +75,8 @@ internal fun Project.configureDokka() = dokkaExtension().run {
7475
//dependsOn(dependenciesOfProject().map(Modules.Module::path))
7576

7677
// Used to remove a source set from documentation, test source sets are suppressed by default
77-
suppress.set(false)
78+
// Dokka V2 only supports one Android variant when debug/release share src/main roots.
79+
suppress.set(!project.isKotlinLibraryGroup() && name != androidPublicationVariant)
7880

7981
// Do not output deprecated members. Applies globally, can be overridden by packageOptions
8082
skipDeprecated.set(false)
@@ -156,4 +158,4 @@ internal fun Project.configureDokka() = dokkaExtension().run {
156158
}
157159
}
158160
}
159-
}
161+
}

0 commit comments

Comments
 (0)