Skip to content

Migrate Room annotation processing from KAPT to KSP#195

Open
dipenpradhan wants to merge 1 commit into
Gurupreet:masterfrom
dipenpradhan:issue-184-room-ksp
Open

Migrate Room annotation processing from KAPT to KSP#195
dipenpradhan wants to merge 1 commit into
Gurupreet:masterfrom
dipenpradhan:issue-184-room-ksp

Conversation

@dipenpradhan

@dipenpradhan dipenpradhan commented Jun 6, 2026

Copy link
Copy Markdown

Summary

Migrates Room annotation processing from KAPT to KSP, as proposed in #184.

  • Replace kotlin-kapt with com.google.devtools.ksp in app/build.gradle.kts and the common-kotlin-module-configs-script-plugin convention plugin (used by :data, :demos:cryptoapp:data, :demos:moviesapp:data)
  • DependencyHandlerExtensions.kt: Room compiler is now added to the ksp configuration instead of kapt
  • Remove the now-unused kapt { correctErrorTypes = true } block from app/build.gradle.kts
  • Add symbol-processing-gradle-plugin:1.9.22-1.0.17 (matching Kotlin 1.9.22) to the buildSrc classpath so the precompiled convention scripts can apply it

KSP runs natively in the Kotlin compiler (no Java stub generation), which speeds up the affected modules' builds. This also unblocks the Kotlin 2.x upgrade (#182): Room 2.6.1's KAPT path cannot read Kotlin 2.1 metadata, while its KSP path is unaffected.

Note: the KSP plugin version intentionally lives next to the other plugin versions in buildSrc/build.gradle.kts rather than Versions.kt, because buildSrc's own build script cannot reference its own sources. It must be bumped in lock-step with Versions.kt's kotlin (the issue's remaining checklist item).

Closes #184

Verification

  • ./gradlew assembleDebug passes locally (JDK 17, SDK 34) — all Room schemas process through KSP
  • CI ./gradlew build on this PR

Merge order

This is PR 1 of a stacked series resolving #182#193 (+ #13, #68). It is based directly on master and can merge independently; the remaining PRs in the series stack on top of it.

🤖 Generated with Claude Code

cc @Gurupreet for review

- Replace kotlin-kapt with com.google.devtools.ksp in the app module
  and the common-kotlin convention plugin
- Add Room compiler via the ksp configuration instead of kapt
- Drop the kapt { correctErrorTypes = true } workaround
- Add symbol-processing-gradle-plugin (1.9.22-1.0.17) to buildSrc

Fixes Gurupreet#184

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@Gurupreet Gurupreet left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Migrates Room annotation processing from KAPT to KSP across the app module and the shared library convention plugin, aligning the build with Room’s recommended processor path and reducing reliance on KAPT.

Changes:

  • Replaced kotlin-kapt with com.google.devtools.ksp in the app module and the shared library convention plugin.
  • Switched Room compiler wiring from the kapt configuration to ksp in DependencyHandlerExtensions.kt.
  • Added the KSP Gradle plugin dependency to buildSrc (to support applying KSP from precompiled convention scripts) and removed the now-unused kapt { correctErrorTypes = true } block from the app module.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
buildSrc/src/main/kotlin/common-kotlin-module-configs-script-plugin.gradle.kts Updates the shared library convention plugin to apply KSP instead of KAPT.
buildSrc/src/main/kotlin/com/guru/composecookbook/build/dependencies/DependencyHandlerExtensions.kt Routes the Room compiler dependency through ksp instead of kapt.
buildSrc/build.gradle.kts Adds KSP Gradle plugin to buildSrc dependencies so convention scripts can apply it.
app/build.gradle.kts Applies KSP and removes the unused KAPT configuration block.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Enhancement: Migrate Room annotation processing from KAPT to KSP

3 participants