注解gradle 4.7+配置未运行lombok [英] annotationProcessor gradle 4.7+ configuration doesn't run lombok

查看:169
本文介绍了注解gradle 4.7+配置未运行lombok的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用gradle 4.7项目时,我收到以下消息

I have received the following message when working with a gradle 4.7 project

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.

跑步时

gradlew build --warning-mode=all

在具有以下Gradle配置的项目上

on a project with the following Gradle configuration

compileOnly('org.projectlombok:lombok')
testCompileOnly('org.projectlombok:lombok')

如警告所示,建议将它们放在annotationProcessor(和testAnnotationProcessor)配置中,以便与gradle 5.0兼容

As the warning suggests, it is recommended to place these on the annotationProcessor (and testAnnotationProcessor) configurations in order to be compatible with gradle 5.0

annotationProcessor('org.projectlombok:lombok')
testAnnotationProcessor('org.projectlombok:lombok')

但是,通过一个简单的测试:

However, with a simple test:

@Slf4j
public class LombokTests {
    @Test
    public void lombokCompiles() {
        log.info("foobar");
    }
}

该配置失败:

> Task :compileTestJava FAILED
D:\Users\bobjones\repos\my-new-app\src\test\java\com\example\app\LombokTests.java:10: error: cannot find symbol
@Slf4j
 ^
  symbol: class Slf4j
1 error

我想念什么吗?

推荐答案

添加compileOnly/testCompileOnly配置

Add the compileOnly/testCompileOnly configuration

annotationProcessor('org.projectlombok:lombok')
compileOnly('org.projectlombok:lombok')
testAnnotationProcessor('org.projectlombok:lombok')
testCompileOnly('org.projectlombok:lombok')


根据文档,注解Processor配置仍然需要compileOnly(对于测试类为testCompileOnly)配置才能起作用.至于对增量注释处理的支持,Lombok的实现者刚刚合并以支持master,但是截至2018年5月25日,还没有包含上线版本.


According to the documentation, the annotationProcessor config still requires the compileOnly (and testCompileOnly for test classes) configuration to function. As for support for incremental annotation processing, the implementers of Lombok have just merged in support to master but as of 25th May 2018 have not included a go-live version.

它们的最新版本16.2.20提交到 2018年1月9日,并且Gradle更改已在 2018年5月15日上成为主版本尽管新版本的"Edgy" 版本不包含与此相关的任何注释,功能.

Their last version 16.2.20 spanning commits up until the 9th of Jan 2018 and the Gradle change was pulled into master on the 15th of May 2018 So I suspect the new version won't be far from release, although their 'Edgy' release does not include any notes regarding this feature.

这篇关于注解gradle 4.7+配置未运行lombok的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆