Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find symbol error: Lombok 1.18.6 does not work with Gradle 5.2.1, JDK 10

Builds with Gradle 5.2.1 and Lombok 1.18.6 dependency are failing with JDK 10. It seems Lombok annotation are not being processed appropriately. I keep getting "cannot find symbol" error across various Java files in my source. Any thoughts on why this might be happening? I found that a defect has already been created: https://github.com/rzwitserloot/lombok/issues/1572

I am using:

Java JDK 10

Gradle 5.2.1

Lombok 1.18.6

Thanks.

like image 406
ap6491 Avatar asked Oct 17 '22 05:10

ap6491


1 Answers

I found the following work around for this issue using a plugin for processing Lombok annotation in compile time.

I had to perform the following steps in build.gradle:

1) Add id "net.ltgt.apt" version "0.15" to plugins section.

2) Add maven { url 'https://projectlombok.org/edge-releases' } to repositories section.

3) Add the following to dependencies section:

compileOnly 'org.projectlombok:lombok:edge-SNAPSHOT'
apt 'org.projectlombok:lombok:edge-SNAPSHOT'

compileOnly 'org.projectlombok:lombok:1.18:6'
annotationProcessor 'org.projectlombok:lombok:1.18:6'

4) Add a task:

tasks.withType(JavaCompile) {
  options.annotationProcessorPath = configurations.apt
}

This lets your build complete successfully.

Update 03/29/2019: This workaround also works with Gradle 5.3, Java JDK 10

Thanks.

like image 82
ap6491 Avatar answered Oct 19 '22 02:10

ap6491