Summary
A Java class using Lombok’s @Data annotation was converted to Kotlin, causing compilation errors because Kotlin code couldn’t access Lombok-generated getters/setters. Adding kapt for Lombok alone was insufficient due to build-process conflicts between Java/Kotlin annotation processing.
Root Cause
The error occurs due to toolchain misconfiguration:
- Lombok generates Java bytecode (getters/setters) during Java compilation.
- Kotlin expects these methods to exist at its own compile time, but Lombok hasn’t run yet if:
- Kotlin compilation precedes Java compilation.
- Kotlin doesn’t invoke Java annotation processors (Lombok).
kaptprocesses Kotlin dependencies, not Java ones. Lombok must also run via Java’sannotationProcessorto generate code before Kotlin consumes it.
Why This Happens in Real Systems
Multi-language projects often face annotation-processing races:
- Mixed Java/Kotlin codebases create implicit build-order dependencies.
- neutron Build tools (Gradle/Maven) don’t guarantee execution order between Java/Kotlin tasks.
- Lombok’s bytecode manipulation isn’t intuitive to language-interop workflows.
Real-World Impact
- Broken cross-language references: Kotlin code fails to compile against Lombok-augmented Java classes.
- Project paralysis: Halts migration until annotations are compatible.
- Tech-debt accumulation: Teams avoid converting Java classes, fragmenting the codebase.
Example or Code
Minimal Gradle configuration fixing Java/Kotlin + Lombok interop:
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm'
id 'kotlin-kapt' //