Class AbsMainProcessPlugin<E extends BaseExtension>
- java.lang.Object
-
- com.ss.android.ugc.bytex.common.AbsPlugin<E>
-
- com.ss.android.ugc.bytex.common.flow.main.AbsMainProcessPlugin<E>
-
- All Implemented Interfaces:
MainProcessHandler,IPlugin,org.gradle.api.Plugin<org.gradle.api.Project>
- Direct Known Subclasses:
CommonPlugin
public abstract class AbsMainProcessPlugin<E extends BaseExtension> extends AbsPlugin<E> implements MainProcessHandler
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.ss.android.ugc.bytex.common.IPlugin
IPlugin.HookType
-
-
Constructor Summary
Constructors Constructor Description AbsMainProcessPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterExecute()插件执行执行结束后的回调,不管成功和失败都会执行.做一些数据回收处理工作voidafterTransform(TransformEngine engine)用于transform完成后,进行各种illegal check It's usually used for plugin's custom illegal check after transform.voidbeforeTransform(TransformEngine engine)用于transform前的准备工作 Prepare for real transform.TransformFlowgetTransformFlow()voidinit()booleanneedPreVerify()这个Handler是不是要求在真正执行前进行一次校验 Verify bytecode before transform.booleanneedVerify()在执行完这个Handler后是否需要进行一次校验 Verify bytecode after transform.java.util.List<FileProcessor>process(Process process)在traverse和transform的过程中,加入自定义的FileProcessor,提供更大的灵活性。 Add custom FileProcessor during traverse or transform.protected TransformFlowprovideTransformFlow(MainTransformFlow mainFlow, TransformContext transformContext)create a new transformFlow or just return mainFlow and append a handler.TransformFlowregisterTransformFlow(MainTransformFlow mainFlow, TransformContext transformContext)Each ByteX plugin can have its own TransformFlow, and the return value of this method determines which flow the plugin runs in.
We mark it as final because TransformFlow should register only oncebooleantransform(java.lang.String relativePath, ClassVisitorChain chain)handle 工程中的所有class To process all classed in the whole project.booleantransform(java.lang.String relativePath, org.objectweb.asm.tree.ClassNode node)handle 工程中的所有class To process all classed in the whole project.voidtraverse(java.lang.String relativePath, ClassVisitorChain chain)遍历工程中所有的class Traverse all classes in the whole project.voidtraverse(java.lang.String relativePath, org.objectweb.asm.tree.ClassNode node)遍历工程中所有的class Traverse all classes in the whole project.voidtraverseAndroidJar(java.lang.String relativePath, ClassVisitorChain chain)遍历android.jar中所有的class Traverse all classes in android.jar.voidtraverseAndroidJar(java.lang.String relativePath, org.objectweb.asm.tree.ClassNode node)遍历android.jar中所有的class Traverse all classes in android.jar.-
Methods inherited from class com.ss.android.ugc.bytex.common.AbsPlugin
alone, apply, createExtension, enable, getExtension, getExtensionClass, getTransform, isRunningAlone, name, onApply, startExecute
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ss.android.ugc.bytex.common.IPlugin
hookTask, hookTask, hookTransformName, shouldSaveCache, transformConfiguration
-
Methods inherited from interface com.ss.android.ugc.bytex.common.flow.main.MainProcessHandler
beforeTraverse, flagForClassReader, flagForClassWriter, init, isOnePassEnough, startRunning, traverseIncremental, traverseIncremental
-
-
-
-
Method Detail
-
init
public void init()
Description copied from interface:MainProcessHandler- Specified by:
initin interfaceMainProcessHandler
-
traverse
public void traverse(@Nonnull java.lang.String relativePath, @Nonnull ClassVisitorChain chain)Description copied from interface:MainProcessHandler遍历工程中所有的class Traverse all classes in the whole project.- Specified by:
traversein interfaceMainProcessHandler- Parameters:
relativePath- class的相对路径。 relative path of classchain- ClassVisitorChain用于加入自定义的ClassVisitor。 ASM visitor api. ClassVisitorChain is used for appending your custom ClassVisitor.
-
traverseAndroidJar
public void traverseAndroidJar(@Nonnull java.lang.String relativePath, @Nonnull ClassVisitorChain chain)Description copied from interface:MainProcessHandler遍历android.jar中所有的class Traverse all classes in android.jar.- Specified by:
traverseAndroidJarin interfaceMainProcessHandler- Parameters:
relativePath- class的相对路径。 relative path of classchain- ClassVisitorChain用于加入自定义的ClassVisitor。 ASM visitor api. ClassVisitorChain is used for appending your custom ClassVisitor.
-
traverse
public void traverse(@Nonnull java.lang.String relativePath, @Nonnull org.objectweb.asm.tree.ClassNode node)Description copied from interface:MainProcessHandler遍历工程中所有的class Traverse all classes in the whole project.- Specified by:
traversein interfaceMainProcessHandler- Parameters:
relativePath- class的相对路径。 relative path of classnode- class的数据结构(照顾喜欢用tree api的同学)。 ASM tree api.
-
traverseAndroidJar
public void traverseAndroidJar(@Nonnull java.lang.String relativePath, @Nonnull org.objectweb.asm.tree.ClassNode node)Description copied from interface:MainProcessHandler遍历android.jar中所有的class Traverse all classes in android.jar.- Specified by:
traverseAndroidJarin interfaceMainProcessHandler- Parameters:
relativePath- class的相对路径。 relative path of classnode- class的数据结构(照顾喜欢用tree api的同学)。 ASM tree api.
-
beforeTransform
public void beforeTransform(@Nonnull TransformEngine engine)Description copied from interface:MainProcessHandler用于transform前的准备工作 Prepare for real transform.- Specified by:
beforeTransformin interfaceMainProcessHandler- Parameters:
engine- from TransformEngine
-
transform
public boolean transform(@Nonnull java.lang.String relativePath, @Nonnull ClassVisitorChain chain)Description copied from interface:MainProcessHandlerhandle 工程中的所有class To process all classed in the whole project.- Specified by:
transformin interfaceMainProcessHandler- Parameters:
relativePath- class的相对路径。 relative path of classchain- ClassVisitorChain用于注册自定义的ClassVisitor。 ASM visitor api. ClassVisitorChain is used for appending your custom ClassVisitor.- Returns:
- if false, this class file would be deleted, otherwise it would be output after transform.
-
transform
public boolean transform(@Nonnull java.lang.String relativePath, @Nonnull org.objectweb.asm.tree.ClassNode node)Description copied from interface:MainProcessHandlerhandle 工程中的所有class To process all classed in the whole project.- Specified by:
transformin interfaceMainProcessHandler- Parameters:
relativePath- class的相对路径。 relative path of classnode- class的数据结构(照顾喜欢用tree api的同学)。。 ASM tree api.- Returns:
- if false, this class file would be deleted, otherwise it would be output after transform.
-
afterTransform
public void afterTransform(@Nonnull TransformEngine engine)Description copied from interface:MainProcessHandler用于transform完成后,进行各种illegal check It's usually used for plugin's custom illegal check after transform.- Specified by:
afterTransformin interfaceMainProcessHandler- Parameters:
engine- from TransformEngine
-
registerTransformFlow
@Nonnull public final TransformFlow registerTransformFlow(@Nonnull MainTransformFlow mainFlow, @Nonnull TransformContext transformContext)
Each ByteX plugin can have its own TransformFlow, and the return value of this method determines which flow the plugin runs in.
We mark it as final because TransformFlow should register only once- Specified by:
registerTransformFlowin interfaceIPlugin- Parameters:
mainFlow- 全局的MainTransformFlow。The global MainTransformFlow- Returns:
- 当前插件关联的TransformFlow,通常返回mainFlow就可以。如果想让插件通过单独一个TransformFlow处理class文件, 这个方法需要另外return 新的TransformFlow(可以是自定义的TransformFlow,也可以new 一个MainTransformFlow)。 If this plugin is related to the global MainTransformFlow, just return `mainFlow` is OK. If you want to handle class files with a single TransformFlow, you should return a new TransformFlow. If so, this new TransformFlow would only contain this plugin.
-
getTransformFlow
public final TransformFlow getTransformFlow()
- Specified by:
getTransformFlowin interfaceIPlugin- Returns:
- get the TransformFlow that the current plugin runs on
-
provideTransformFlow
protected TransformFlow provideTransformFlow(@Nonnull MainTransformFlow mainFlow, @Nonnull TransformContext transformContext)
create a new transformFlow or just return mainFlow and append a handler. It will be called byIPlugin.registerTransformFlow(MainTransformFlow, TransformContext)when handle start.- Parameters:
mainFlow- main TransformFlowtransformContext- handle context- Returns:
- return a new TransformFlow object if you want make a new flow for current plugin
-
process
public java.util.List<FileProcessor> process(Process process)
Description copied from interface:MainProcessHandler在traverse和transform的过程中,加入自定义的FileProcessor,提供更大的灵活性。 Add custom FileProcessor during traverse or transform.- Specified by:
processin interfaceMainProcessHandler- Parameters:
process- enum- Returns:
- list of FileProcessor
-
needPreVerify
public boolean needPreVerify()
Description copied from interface:MainProcessHandler这个Handler是不是要求在真正执行前进行一次校验 Verify bytecode before transform.- Specified by:
needPreVerifyin interfaceMainProcessHandler- Returns:
- if true, indicate that need to verify bytecode. Default is false.
-
needVerify
public boolean needVerify()
Description copied from interface:MainProcessHandler在执行完这个Handler后是否需要进行一次校验 Verify bytecode after transform.- Specified by:
needVerifyin interfaceMainProcessHandler- Returns:
- if true, indicate that need to verify bytecode. Default is false.
-
afterExecute
public void afterExecute() throws java.lang.ThrowableDescription copied from interface:IPlugin插件执行执行结束后的回调,不管成功和失败都会执行.做一些数据回收处理工作- Specified by:
afterExecutein interfaceIPlugin- Overrides:
afterExecutein classAbsPlugin<E extends BaseExtension>- Throws:
java.lang.Throwable
-
-