ap6491
ap6491

Reputation: 835

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.

Upvotes: 5

Views: 5093

Answers (1)

ap6491
ap6491

Reputation: 835

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.

Upvotes: 3

Related Questions