Skip to content

Add KSP plugin support for android_binary and android_library#195

Merged
minkuanlim-grabtaxi merged 2 commits intograb:masterfrom
minkuan88:ksp-support
Jan 9, 2026
Merged

Add KSP plugin support for android_binary and android_library#195
minkuanlim-grabtaxi merged 2 commits intograb:masterfrom
minkuan88:ksp-support

Conversation

@minkuan88
Copy link
Contributor

@minkuan88 minkuan88 commented Jan 7, 2026

Summary

This PR adds support for KSP (Kotlin Symbol Processing) plugins in android_binary and android_library macros.

Problem

Previously, the plugins attribute was passed directly to the native android_binary rule. However, KSP plugins need to be invoked during the Kotlin compilation phase, not at the binary packaging stage. This meant KSP processors were not being executed.

Solution

Move the plugins attribute from android_binary to kt_jvm_library, ensuring KSP processors are invoked during Kotlin compilation where they can properly generate code.

Changes

  • Move plugins attribute from android_binary to kt_jvm_library for proper KSP execution
  • Update Kotlin to 1.9.25 with KSP 1.9.25-1.0.20
  • Add Dagger 2.52 in separate test maven repository to validate KSP integration

Testing

Added dagger-compiler as a KSP plugin to both android_binary and android_library
test targets to validate the integration. Test implementation includes Dagger
@Component interfaces with @Inject dependencies, where test activities invoke
the generated factory code to verify KSP processors execute correctly during
Kotlin compilation.

Move plugins attribute from android_binary to kt_jvm_library so that
KSP processors are invoked during Kotlin compilation phase rather than
at the binary packaging stage.

Changes:
- Pass plugins attribute to kt_jvm_library in android_binary macro
- Update Kotlin compiler to 1.9.25 with KSP 1.9.25-1.0.20
- Add room-compiler as a test KSP plugin to validate the integration
- Update related dependencies (kotlinpoet, symbol-processing-api)
Replace androidx.room with Dagger as the KSP processor in test targets
to better validate KSP integration with dependency injection workflows.

Changes:
- Replace room-compiler with dagger-compiler as KSP test processor
- Create separate bazel_common_test_maven repository for Dagger 2.52
- Add Dagger components with @Inject dependencies in test modules:
  * LibraryActivityComponent with SomeDependency in android_library
  * TestActivityComponent with SimpleDependency in android_binary
- Split dependency classes from component interfaces into separate files
  for better code organization
- Update test activities to invoke Dagger-generated factory code
- Remove room-compiler from main maven dependencies

This validates that KSP plugins properly invoke annotation processors
during Kotlin compilation phase in both android_binary and android_library
targets.
@minkuanlim-grabtaxi minkuanlim-grabtaxi merged commit 8cfb7bc into grab:master Jan 9, 2026
3 checks passed
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.

3 participants