-
Notifications
You must be signed in to change notification settings - Fork 243
Description
Kotlin + Lombok mixed-mode compilation breaks (missing Lombok-generated methods)
Environment
-
Bazel: (add your version)
-
rules_kotlin: 1.9.x
-
rules_java: bundled
-
rules_jvm_external: (version)
-
Platform: macOS (dev), Linux (CI)
🚨 Summary of the Problem
Our project contains mixed Java + Kotlin source sets where:
-
Kotlin code calls Java classes
-
Java classes use Lombok, generating getters/setters
-
Java code also references Kotlin classes
This creates a circular dependency:
Kotlin → needs Lombok-generated Java methods Java → needs Kotlin classes Lombok → needs Java compilation before Kotlin
Under Maven/Gradle this works because Java + Kotlin + Lombok compile in a unified phase.
Under rules_kotlin, the Kotlin compiler sees the raw Java source before Lombok runs, causing missing symbol errors.
❌ Errors We Get
error: cannot find symbol sessionStorage.setUserId(...) ^ symbol: method setUserId(String) location: variable sessionStorage of type SessionStorage
But these methods are generated by Lombok — they should exist.
✔ What We Have Tried
Nothing resolves the core issue:
rules_kotlin does not support mixed Java + Kotlin compilation where annotation processors must run before Kotlin.
🧪 Minimal Reproduction
Java (with Lombok)
@Data public class SessionStorage { private String userId; }
Kotlin (uses Lombok-generated getter)
class PremiumClient(private val session: SessionStorage) { fun test() = session.userId // Fails: no getter found }
Java referencing Kotlin
public class AuthService { private final PremiumClient client = new PremiumClient(new SessionStorage()); }
🤔 Expected Behavior
-
Lombok should generate getters/setters before Kotlin is compiled.
-
Kotlin should compile against bytecode, not the raw Java source.
-
Mixed Java/Kotlin source sets should be supported, like Gradle or Maven.
💥 Actual Behavior
-
Kotlin compiler is invoked before Lombok-generated bytecode exists.
-
It cannot resolve methods that Lombok would generate.
-
Java compilation then fails because Kotlin compilation failed.
🎯 What We Are Requesting
1️⃣ Official Lombok support for mixed Java + Kotlin compilation
Something equivalent to:
-
Java annotation processing
-
Kotlin + Java compilation in a single step
-
kaptcompatibility or alternative
2️⃣ A unified compile action
Where:
-
Java annotation processors run first
-
Kotlin compiles against their bytecode
3️⃣ Documentation or recommended path
For projects migrating from Maven → Bazel that use:
-
Spring Boot
-
Lombok
-
Kotlin
-
Java legacy code
This combination is extremely common in enterprise projects.
🧩 Why This Matters
Many real-world projects depend on:
-
Spring Boot
-
Lombok
-
Kotlin for new features
-
Java for legacy components
These mixed source sets are widely used and currently cannot compile in Bazel using rules_kotlin without major restructuring.
A unified solution would benefit many teams across the ecosystem.