Skip to content

Kotlin + Lombok mixed-mode compilation breaks (missing Lombok-generated methods) #1427

@abdi810103

Description

@abdi810103

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:

  1. Kotlin code calls Java classes

  2. Java classes use Lombok, generating getters/setters

  3. 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

Attempt | Result -- | -- Adding Lombok via kt_compiler_plugin | ❌ Not recognized / no effect Using kapt | ❌ Fails with internal FIR errors Forcing annotation processors | ❌ Kotlin still sees raw Java Disabling header compilation | ❌ Did not fix Splitting sources into multiple libraries | ❌ Breaks circular dependencies Converting Java → Kotlin | ⚠ Works but not viable long-term

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

  • kapt compatibility 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.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions