Skip to content

Phase 1.0b: Convert all Gradle build scripts to Kotlin DSL - #20

Merged
sjaramillo10 merged 2 commits into
masterfrom
3-10b-convert-build-files-to-kotlin-dsl-buildgradlekts
May 26, 2026
Merged

sjaramillo10 merged 2 commits into
masterfrom
3-10b-convert-build-files-to-kotlin-dsl-buildgradlekts

Conversation

@sjaramillo10

Copy link
Copy Markdown
Owner

Linked issue

Closes #3.

What changed

  • Every .gradle file in the repo became .gradle.kts: settings.gradle, root build.gradle, detekt/detekt.gradle, and all 14 module build files. Pure syntax conversion on top of the 1.0a version catalog — no dependency or version changes.
  • settings.gradle.kts adds a pluginManagement block with gradlePluginPortal(), google(), and mavenCentral(). Required because Paparazzi's transitive com.android.tools:sdk-common only resolves from Google Maven.
  • detekt/detekt.gradle.kts removed; detekt config folded into root build.gradle.kts. Script plugins loaded via apply(from = ...) run with their own compilation classpath and can't see plugin extension types (DetektExtension). Inlining into the allprojects {} block preserves identical behavior with cleaner KTS semantics.
  • Plugin application convention captured during conversion:
    • Plugins on the buildscript classpath (AGP, Kotlin, Karumi shot, Vanniktech maven-publish) use plain id("...") in module scripts with no version.
    • Plugins resolved through pluginManagement (KSP, compose-compiler, paparazzi, detekt) use alias(libs.plugins.*).
    • Mixing the two for the same plugin produces "plugin already on classpath with unknown version" errors. Documented in CLAUDE.md.
  • One deviation from strict syntax-only conversion: the afterEvaluate { ... } block in showkase-screenshot-testing-paparazzi-sample/build.gradle was a workaround for KSP issue Setup for testing the annotation processor airbnb/Showkase#37 (fixed in KSP 1.0.7, June 2022). KSP 2.x — what we run — registers generated Kotlin sources automatically, so the block was already a no-op. Dropped during conversion with an inline comment explaining the rationale and how to restore if a regression surfaces.
  • CLAUDE.md updated: notes the Kotlin DSL state, plugin convention, pluginManagement repos, and prunes the now-shipped catalog/KTS entries from the "Keep this file in sync" examples.

How to validate locally

./gradlew check assembleDebug :showkase-processor:test

Ran locally: green in 3m30s, 762 actionable tasks executed. CI runs the same.

CI status

ci.yml will run check assembleDebug :showkase-processor:test on JDK 17. Expecting green.

Out-of-scope follow-ups

  • Phase 1.1 (1.1 Drop KAPT entirely (KSP-only path) #5): drop the useKsp toggle and KAPT branches everywhere. Plugin alias kotlin-kapt becomes unused and can be removed from the catalog.
  • Phase 1.2 (1.2 Bump toolchain: AGP 9, Kotlin 2.3, KSP2, Compose 1.11, Gradle 9.1+, Detekt #6): bump AGP / Kotlin / KSP / Compose / Gradle; surfaces a number of AGP DSL deprecation warnings during this run (packagingOptions → packaging, library targetSdk, etc.) that should be addressed at the toolchain bump.
  • Phase 1.2 follow-up: re-evaluate whether vanniktech maven-publish can move off the buildscript classpath entirely and use plugin-portal resolution (one of the few duplications between buildscript classpath and root plugins block).

Replaces every Groovy build script in the repo with its KTS
equivalent:

- settings.gradle → settings.gradle.kts (also adds pluginManagement
  block with gradlePluginPortal + google + mavenCentral, required so
  Paparazzi's transitive com.android.tools:sdk-common resolves from
  Google Maven)
- build.gradle (root) → build.gradle.kts (folds the detekt
  configuration directly into the allprojects block; see below)
- detekt/detekt.gradle removed — script plugins applied via
  apply(from = ...) run with their own compilation classpath and
  cannot see plugin extension types like DetektExtension. Inlining
  the config into the root build.gradle.kts allprojects {} block
  preserves identical behavior with cleaner KTS semantics.
- All 14 module build.gradle files → build.gradle.kts.

Plugin application convention:
- Plugins on the buildscript classpath (AGP, Kotlin, shot,
  vanniktech maven-publish) use plain id("...") in module scripts
  with no version (version comes from the buildscript classpath).
- Plugins resolved through pluginManagement (ksp, compose-compiler,
  paparazzi, detekt) use alias(libs.plugins.*).
- Mixing alias() with a plugin already on the buildscript classpath
  produces "plugin already on classpath with unknown version"
  errors at configuration time.

Other notes captured during the conversion:
- The afterEvaluate block in showkase-screenshot-testing-paparazzi-
  sample/build.gradle was a workaround for KSP issue airbnb#37 (fixed in
  KSP 1.0.7, June 2022). KSP 2.x — which we use — registers
  generated Kotlin sources automatically, so the block was a no-op
  and has been dropped during conversion. Documented inline.

Local verification: ./gradlew check assembleDebug
:showkase-processor:test passes (3m30s, 762 actionable tasks).

Refs #3
- "Kotlin DSL throughout" replaces the prior Groovy DSL note.
- Documents the plugin application convention surfaced during
  conversion: id(...) for buildscript-classpath plugins, alias(...)
  for plugin-portal plugins.
- Notes the pluginManagement block in settings.gradle.kts and why
  google() is required there (paparazzi transitive deps).
- Drops the "no version catalog yet" line — catalog landed in 1.0a.
- Updates path references from build.gradle to build.gradle.kts.
- Prunes the catalog/KTS entries from the "Keep this file in sync"
  examples now that those phases have shipped.
@sjaramillo10 sjaramillo10 linked an issue May 26, 2026 that may be closed by this pull request
@sjaramillo10
sjaramillo10 enabled auto-merge (squash) May 26, 2026 02:22
@sjaramillo10
sjaramillo10 merged commit 0d7d027 into master May 26, 2026
1 check passed
@sjaramillo10
sjaramillo10 deleted the 3-10b-convert-build-files-to-kotlin-dsl-buildgradlekts branch May 26, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.0b Convert build files to Kotlin DSL (build.gradle.kts)

1 participant