Fixed the incremental invalidation of the annotation processor #916
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
致Arouter开发组:
当前
Arouter
并不属于isolating
类型的增量型注解处理器.ioslating
:有一条限制,一个注解映射一个单独的文件,不可多个注解映射单个文件.在
RouteProcessor
中会将多个@route归并到一个文件,违反了isolating
规定.且没有给文件传入originating element
.官方文档链接
你可以仔细看到gradle编译过程的抛出的异常信息:
Arouter
所使用的处理器都属于aggregating
类型增量注解处理器.此
PR
经过本文严格测试发现编译时有效.下面给出一个复现问题步骤:
我们以
module-kotlin
模块为例运行gradle命令:
:app:compileDebugJavaWithJavac
module-kotlin/build/generated/source/kapt 文件下会生成对应的文件
注释掉
TestNormalActivity
对应@route(path = "/kotlin/java"):app:compileDebugJavaWithJavac
module-kotlin/build/generated/source/kapt
这个文件夹会整个全部删除重建,证明增量失败当前版本如果修改对应
Arouter
相关类会将其他库的文件一起删除重建(如Dagger生成的文件),这将给大型工程带来巨大的编译时效问题.拉取PR后您可按上述步骤进行实际校验是否有效.另外当您拉取PR后,请删除所有build文件夹在测试,因为gradle存在一个bug,如果之前存在非增量的环境,现在变成了增量环境也是非增量的.相关gradle issue .
由于我所在的工程存在大量apt模块,所以每次改动
Arouter
相关代码将带来不可小觑的编译时间问题.为了解决这个问题,我不得以clone后在内网发布另一个版本,但是随着Arouter
的迭代,我也要跟着拉取合并.