Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the incremental invalidation of the annotation processor #916

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

fanmingyi
Copy link
Contributor

致Arouter开发组:
当前Arouter并不属于 isolating类型的增量型注解处理器.
ioslating:有一条限制,一个注解映射一个单独的文件,不可多个注解映射单个文件.
RouteProcessor中会将多个@route归并到一个文件,违反了isolating规定.且没有给文件传入 originating element.

官方文档链接

image

你可以仔细看到gradle编译过程的抛出的异常信息:
image

Arouter所使用的处理器都属于aggregating类型增量注解处理器.

PR经过本文严格测试发现编译时有效.

下面给出一个复现问题步骤:

我们以module-kotlin模块为例

  1. 运行gradle命令::app:compileDebugJavaWithJavac

  2. module-kotlin/build/generated/source/kapt 文件下会生成对应的文件

  3. 注释掉TestNormalActivity对应@route(path = "/kotlin/java")

//注释以下代码检测是否增量
//@Route(path = "/kotlin/java")
public class TestNormalActivity extends AppCompatActivity {

}
  1. 运行gradle命令::app:compileDebugJavaWithJavac
  2. module-kotlin/build/generated/source/kapt这个文件夹会整个全部删除重建,证明增量失败

当前版本如果修改对应Arouter相关类会将其他库的文件一起删除重建(如Dagger生成的文件),这将给大型工程带来巨大的编译时效问题.
拉取PR后您可按上述步骤进行实际校验是否有效.另外当您拉取PR后,请删除所有build文件夹在测试,因为gradle存在一个bug,如果之前存在非增量的环境,现在变成了增量环境也是非增量的.相关gradle issue .

由于我所在的工程存在大量apt模块,所以每次改动Arouter相关代码将带来不可小觑的编译时间问题.为了解决这个问题,我不得以clone后在内网发布另一个版本,但是随着Arouter的迭代,我也要跟着拉取合并.

@CLAassistant
Copy link

CLAassistant commented May 1, 2021

CLA assistant check
All committers have signed the CLA.

@zhi1ong zhi1ong merged commit e644bcf into alibaba:develop Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants