Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lombok Annotations not processing in tests - Bazel

I am trying to use Lombok for a project along with Bazel. The Lombok annotations are not resolved in the test files. Does anyone have suggestions on how to resolve this issue?

I have enabled the Lombok Plugin and Annotation Processing in IntelliJ

java_library(
    name = "lombok",
    exports = [
        "@maven//:org_projectlombok_lombok",
    ],
    exported_plugins = [
        ":lombok_plugin"
    ],
)

java_plugin(
    name = "lombok_plugin",
    processor_class = "lombok.launch.AnnotationProcessorHider$AnnotationProcessor",
    deps = [
        ":lombok_jar",
    ],
)

java_import(
    name = "lombok_jar",
    jars = [
      "@maven//:v1/https/repo1.maven.org/maven2/org/projectlombok/lombok/1.18.20/lombok-1.18.20.jar"
    ],
)

Thanks

like image 860
Vishwa Patel Avatar asked Nov 17 '25 04:11

Vishwa Patel


1 Answers

You need to disable header compilation for lombok objects to work across targets - add the below snippet in .bazelrc

# See https://github.com/bazelbuild/bazel/issues/12837.
build --nojava_header_compilation
test --nojava_header_compilation
like image 154
Vishwa Patel Avatar answered Nov 18 '25 18:11

Vishwa Patel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!