gpt4 book ai didi

gradle - 解决 Micronaut 和 Gradle 5 "Detecting annotation processors on the compile classpath is deprecated"警告的警告

转载 作者:行者123 更新时间:2023-12-03 04:19:45 24 4
gpt4 key购买 nike

我正在尝试从 Gradle 解决以下警告。它仅在我调用测试代码时发生。主要的 Java(仅)运行和构建任务工作正常。

测试代码在 Groovy 中。似乎 Groovy 与 Gradle 和 Micronaut 结合在几周前解决了该消息但顽固地坚持在 test 上的项目中提出了此消息。和 testCompile相关任务。

> Task :plumbing:compileTestGroovy
The following annotation processors were detected on the compile classpath:
'io.micronaut.annotation.processing.TypeElementVisitorProcessor' and 'io.micronaut.annotation.processing.PackageConfigurationInjectProcessor' and
'io.micronaut.annotation.processing.BeanDefinitionInjectProcessor'.
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.

从 Micronaut 开始,我通过反复试验发现使用 Lombok 的说明到目前为止,运行 Groovy 测试的唯一方法是使用 build.gradle 中的以下配方文件。 Micronaut 配方指定将 Lombok 放在 Micronaut 之前。这对 Java 构建有效。

为了让 Groovy 代码编译然后执行,我(似乎)需要这样编写我的依赖项:
configurations {
annotationProcessor
}

dependencies
{
compileOnly (
dep_lombok // Must come first
)

annotationProcessor (
dep_lombokAtnProc, // Must come first
dep_micronautAtnProc
)

compileOnly (
dep_micronaut // Must follow annotationProcessor
)

implementation (
project( ':base'),
)

testImplementation (
project( ':TestingSupport')
)

testImplementation (
dep_micronaut,
dep_commonsConfig
)
}
  • 依赖关系 dep_XXX只是字符串。
  • AtnProc...”标签是专门标识注解处理器(即使它是同一个坐标)。

  • 如果 compileOnly ( dep micronaut )条款对于诸如 @Inject 之类的事情是必要的使用 Groovy 构建进行处理。和 ...
  • 它必须按照显示的顺序,在 annotationProcessor(..) 之后。条款。

  • 尽管此时 Groovy 文件中没有注释。

    使用上述构建信息,Groovy 规范可以正常运行和工作。但是我仍然得到 Deprecated ...警告。

    没有 compileOnly( Micronaut )短语我得到编译错误并且没有运行。 testCompileOnly , 一个 groovyCompileOnlytestAnnotationProcessor没做什么。

    谁知道在使用 Micronaut 时如何使用 Gradle 构建和运行 Groovy 测试?测试与 Lombok 罚款共存。

    缺少的东西是 @Inject , @Singleton , ETC。

    期待建议和想法。

    最佳答案

    添加 annotationProcessor 后,主模块的警告已解决。配置但继续为您的测试模块,会让我相信注释处理器正在您的测试代码中使用。

    类似于 kapt Kotlin annotation processor插件,我相信您需要使用 testAnnocationProcessor 为您的测试模块配置注释处理器如下:

        testAnnotationProcessor (
    dep_lombokAtnProc,
    dep_micronautAtnProc
    )

    关于gradle - 解决 Micronaut 和 Gradle 5 "Detecting annotation processors on the compile classpath is deprecated"警告的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51701173/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com