gpt4 book ai didi

android - 检查 kapt 是否使用增量注释处理

转载 作者:行者123 更新时间:2023-12-02 12:05:58 25 4
gpt4 key购买 nike

在 Kotlin 1.3.30 中添加了对增量注释处理的支持:https://blog.jetbrains.com/kotlin/2019/04/kotlin-1-3-30-released/
根据文档:

Note that in the current implementation, using any non-incremental annotation processor or a change in dependency’s ABI (so far, including modifying internal declarations) will lead to non-incremental annotation processing for a given module.



我有一个带有多个注释处理器的多模块项目。只有其中一些是增量的。至少据我所知,有些模块仅使用增量注释处理器。

我的问题是:
有没有办法检查是否发生了增量注释处理?例如。 Gradle中是否有任何特定的控制台日志表明这一点?我想确认实际上使用了增量注释处理。

最佳答案

我能够通过添加来确定

kapt.verbose=true

gradle.properties在根项目中。
这会导致在控制台中打印以下内容,例如改变公共(public)方法:
Javac options: {}
[incremental apt] Changed files: [/Users/me/workspace/my-project/core/common/build/tmp/kapt3/stubs/foo/bar/ChangedClassName.java]
...
[INFO] Need to discovery annotation processors in the AP classpath
[INFO] Annotation processors: toothpick.compiler.factory.FactoryProcessor, toothpick.compiler.memberinjector.MemberInjectorProcessor
[INFO] Processing java sources with annotation processors: /Users/me/workspace/my-project/core/common/build/tmp/kapt3/stubs/foo/bar/ChangedClassName.java
[INFO] Annotation processing complete, errors: 0, warnings: 0
[INFO] Annotation processor stats:
[INFO] IncrementalProcessor: total: 61 ms, init: 1 ms, 3 round(s): 59 ms, 0 ms, 1 ms
[INFO] IncrementalProcessor: total: 1 ms, init: 1 ms, 3 round(s): 0 ms, 0 ms, 0 ms

这是使用增量注释处理的时候。
进行干净构建时,会打印:
Javac options: {}
[incremental apt] Changed files: []
...
[INFO] Need to discovery annotation processors in the AP classpath
[INFO] Annotation processors: toothpick.compiler.factory.FactoryProcessor, toothpick.compiler.memberinjector.MemberInjectorProcessor
[INFO] Processing java sources with annotation processors: [ALL THE FILES IN THE MODULE ARE LISTED HERE]
[INFO] Annotation processing complete, errors: 0, warnings: 0
[INFO] Annotation processor stats:
[INFO] IncrementalProcessor: total: 124 ms, init: 1 ms, 3 round(s): 122 ms, 1 ms, 0 ms
[INFO] IncrementalProcessor: total: 1 ms, init: 0 ms, 3 round(s): 1 ms, 0 ms, 0 ms

Toothpick 是我正在使用的 DI 框架,它从 2.x 开始支持增量注释处理。

如果有一个不是增量的注释处理器,这也会打印例如:
[INFO] Incremental KAPT support is disabled. Processors that are not incremental: butterknife.compiler.ButterKnifeProcessor.

关于android - 检查 kapt 是否使用增量注释处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56132463/

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