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

梦想与她 提交于 2019-12-11 10:48:33

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/55227728/cannot-find-symbol-error-lombok-1-18-6-does-not-work-with-gradle-5-2-1-jdk-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!