Environment:
JDK 17
Gradle 7.x (also tried 8.x)
Lombok gradle plugin 7.x (or 8.x) (also tried Lombok 1.18.30 directly)
When I try to compile my code using ./gradlew clean compileJava, the build fails randomly around 50% of the time. with javac errors like these on Lombok-annotated classes:
/Users/sunil/...XYZService.java:36: error: cannot find symbol
@RequiredArgsConstructor(onConstructor_ = { @Autowired })
^
symbol: method onConstructor_()
location: @interface RequiredArgsConstructor
/Users/sunil/...XYZService.java:36: error: cannot find symbol
private void getCredit(Discovery.DiscoveryBuilder builder) {
^
symbol: class DiscoveryBuilder
location: class Discovery
- I have gone through all ~300 reported javac errors, I cannot find anything problematic in the code.
- There is no pattern - if I run the exact build thing again and again, sometimes compile succeeds, sometimes it fails.
- This very same code always compiles fine inside Eclipse IDE.
- I am using only these common Lombok annotations: AllArgsConstructor, RequiredArgsConstructor, NoArgsConstructor, Builder, Builder.Default, Data, Getter, Setter, NonNull, ToString, Slf4j.
- I have run Gradle with --debug and confirmed that Lombok is indeed in the processorpath and classpath of javac.
- I have tried 2 different JDK 17s: Corretto and OpenJDK. No difference.
- I tried Gradle with and without the Lombok plugin. No difference.
- The problem happens on both MacOS and Amazon Linux.
I have been through any number of threads on SO and here, and I see people saying that there must be some class somewhere which has something Lombok doesn't "like". But how on earth do I find it?? I would appreciate any help, since this is driving me crazy now.
Many thanks,
Sunil
[This communication contains information which is confidential and may also be legally privileged. It is for the exclusive use of the intended recipient/s. If you have received this communication in error, please delete the email and destroy any copies of it.]