-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core.transform-kit): 简化代码,并剥离对旧Transform API的依赖到Wrapper类
ClassTransform是抽象的,它不知道字节码编辑工具是Javassist,也不知道Transform框架是AGP的还是Gradle的。 它定义了TransformInput,由外部Transform框架的适配器(如DeprecatedTransformWrapper)将外部Transform 框架的输入适配进来。 TransformInput支持DIR和JAR两种输入,对应ClassTransform.input中通过TransformInput拿到输入的class文件或 jar文件,然后交给loadDotClassFile和loadClassFromJar两个抽象方法加载类到字节码编辑框架中。 input同时将加载的类名记录到TransformInput.getInputClassNames中,以便output时知道该输出哪些类。 注意1个TransformInput对应多个Class。 此次简化去掉了InputClass类。这个类之前主要的作用是记录每个输入的class对应的输出文件。 这个输出文件其实不需要逐个记录路径或者entryname,可以由类名自己拼接出来。 所以这次简化改为了在output时再根据classname生成文件路径和entryname。 将ctClassInputMap: Map<CtClass, InputClass>改为allInputCtClass: Set<CtClass> ,去掉renameOutput方法,都是因为早在 f1d0f5b 引入新的Fragment支持方案时, 就不再需要修改输出类名。也就是现在所有Transform操作都不会影响输入的类名,也不会增加或减少类。 因此不再需要将控制输出文件的InputClass传给TransformManager。 最后将对已经Deprecated,即将在AGP 8中删除的Transform API的依赖代码都移到DeprecatedTransformWrapper中。 #1212
- Loading branch information
Showing
8 changed files
with
285 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.