升级到 gradle 4.7 后,我之前没有警告的构建现在会发出以下警告:
The following annotation processors were detected on the compile classpath: 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor' and 'lombok.launch.AnnotationProcessorHider$ClaimingProcessor'. Detecting annotation processors on the compile classpath is deprecated and Gradle 5.0 will ignore them. Please add them to the annotation processor path instead. If you did not intend to use annotation processors, you can use the '-proc:none' compiler argument to ignore them.
注释处理器似乎已被弃用,gradle 5.0 版将不支持注释处理器。
我的项目使用 lombok,它需要注释处理器,所以使用 -proc:none
不是一个选项。发布 5.0 版时也不会停止使用 Gradle。
我该怎么做:
- 停止警告,然后
- 确保我的项目将在未来的 Gradle 版本中继续构建?
最佳答案
将 lombok 依赖类型从 compile
更改为 annotationProcessor
,因此 build.gradle
文件中的依赖项部分应如下所示:
dependencies {
compileOnly('org.projectlombok:lombok:1.16.20')
annotationProcessor 'org.projectlombok:lombok:1.16.20'
// compile 'org.projectlombok:lombok:1.16.20' <-- this no longer works!
// other dependencies...
}
关于java - Gradle 已弃用 lombok 的注释处理器警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50202843/