@@ -28,73 +28,73 @@ dependencies {
2828}
2929
3030
31- buildscript {
32- repositories {
33- maven {
34- url uri(' ../repo' )
35- }
36- }
37- dependencies {
38- classpath ' com.threetrees.plugin:plugin:1.0.0'
39- }
40- }
41-
42- apply plugin : ' ttreeplugin'
43-
44- import com.threetrees.plugin.asm.AutoMethodVisitor
45- import org.objectweb.asm.MethodVisitor
46- import org.objectweb.asm.Opcodes
47-
48- ttree {
49- isDebug = true
50- // 具体配置
51- matchData = [
52- // 'AnnotationPath' : 'com.threetree.ttreeplugin.annotation',
53- // 'AnnotationReceiver' : 'com.threetree.ttreeplugin.MyReceiver',
54- // 'ClassReceiver' : 'com.threetree.ttreeplugin.MyReceiver',
55- ' ClassFilter' : [
56- // 根据类型匹配
57- [' ClassName' : ' com/threetree/ttreeplugin/MainActivity' ,
58- ' MethodName' : ' testClassName' , ' MethodDes' : ' ()V' ],
59- // 根据类型匹配
60- [' ClassName' : ' com/threetree/ttreeplugin/MainActivity' ,
61- ' MethodName' : ' testBoolean' , ' MethodDes' : ' (Z)V' ],
62- // 根据关键字匹配
63- [' ContainName' : ' Activity' ,
64- ' MethodName' : ' testContainName' , ' MethodDes' : ' (Ljava/lang/String;)V' ],
65- // 根据接口名匹配
66- [' InterfaceName' : ' android/view/View$OnClickListener' ,
67- ' MethodName' : ' onClick' , ' MethodDes' : ' (Landroid/view/View;)V' ],
68- // 根据类型匹配,外部配置覆盖
69- [' ClassName' : ' com/threetree/ttreeplugin/MainActivity' ,
70- ' MethodName' : ' testOverride' , ' MethodDes' : ' ()V' , ' Override' : true ],
71- // 根据类型匹配,拦截方法
72- [' ClassName' : ' com/threetree/ttreeplugin/MainActivity' ,
73- ' MethodName' : ' testInterceptForClass' , ' MethodDes' : ' ()I' ]
74- ],
75- // 插入的字节码,方法的执行顺序visitAnnotation->onMethodEnter->onMethodExit
76- ' MethodVisitor' : {
77- MethodVisitor mv, int access, String name, String desc, String className ->
78- AutoMethodVisitor adapter = new AutoMethodVisitor (mv, access, name, desc, className) {
79- @Override
80- protected void onMethodEnter () {
81- super . onMethodEnter();
82- if (" testOverride" . equals(name))
83- {
84-
85- mv. visitLdcInsn(name)
86- mv. visitLdcInsn(" ========start=========" )
87- mv. visitMethodInsn(Opcodes . INVOKESTATIC , " android/util/Log" , " e" , " (Ljava/lang/String;Ljava/lang/String;)I" , false )
88- }
89- }
90-
91- @Override
92- protected void onMethodExit (int opcode ) {
93- super . onMethodExit(opcode)
94- }
95- }
96- return adapter
97- }
98- ]
99- }
31+ // buildscript {
32+ // repositories {
33+ // maven {
34+ // url uri('../repo')
35+ // }
36+ // }
37+ // dependencies {
38+ // classpath 'com.threetrees.plugin:plugin:1.0.0'
39+ // }
40+ // }
41+ //
42+ // apply plugin: 'ttreeplugin'
43+ //
44+ // import com.threetrees.plugin.asm.AutoMethodVisitor
45+ // import org.objectweb.asm.MethodVisitor
46+ // import org.objectweb.asm.Opcodes
47+ //
48+ // ttree {
49+ // isDebug = true
50+ // //具体配置
51+ // matchData = [
52+ // // 'AnnotationPath' : 'com.threetree.ttreeplugin.annotation',
53+ // // 'AnnotationReceiver' : 'com.threetree.ttreeplugin.MyReceiver',
54+ // // 'ClassReceiver' : 'com.threetree.ttreeplugin.MyReceiver',
55+ // 'ClassFilter' : [
56+ // //根据类型匹配
57+ // ['ClassName' : 'com/threetree/ttreeplugin/MainActivity',
58+ // 'MethodName': 'testClassName', 'MethodDes': '()V'],
59+ // //根据类型匹配
60+ // ['ClassName' : 'com/threetree/ttreeplugin/MainActivity',
61+ // 'MethodName': 'testBoolean', 'MethodDes': '(Z)V'],
62+ // //根据关键字匹配
63+ // ['ContainName' : 'Activity',
64+ // 'MethodName': 'testContainName', 'MethodDes': '(Ljava/lang/String;)V'],
65+ // //根据接口名匹配
66+ // ['InterfaceName': 'android/view/View$OnClickListener',
67+ // 'MethodName': 'onClick', 'MethodDes': '(Landroid/view/View;)V'],
68+ // //根据类型匹配,外部配置覆盖
69+ // ['ClassName' : 'com/threetree/ttreeplugin/MainActivity',
70+ // 'MethodName': 'testOverride', 'MethodDes': '()V', 'Override' : true],
71+ // //根据类型匹配,拦截方法
72+ // ['ClassName' : 'com/threetree/ttreeplugin/MainActivity',
73+ // 'MethodName': 'testInterceptForClass', 'MethodDes': '()I']
74+ // ],
75+ // //插入的字节码,方法的执行顺序visitAnnotation->onMethodEnter->onMethodExit
76+ // 'MethodVisitor': {
77+ // MethodVisitor mv, int access, String name, String desc, String className ->
78+ // AutoMethodVisitor adapter = new AutoMethodVisitor(mv, access, name, desc, className) {
79+ // @Override
80+ // protected void onMethodEnter() {
81+ // super.onMethodEnter();
82+ // if("testOverride".equals(name))
83+ // {
84+ //
85+ // mv.visitLdcInsn(name)
86+ // mv.visitLdcInsn("========start=========")
87+ // mv.visitMethodInsn(Opcodes.INVOKESTATIC, "android/util/Log", "e", "(Ljava/lang/String;Ljava/lang/String;)I", false)
88+ // }
89+ // }
90+ //
91+ // @Override
92+ // protected void onMethodExit(int opcode) {
93+ // super.onMethodExit(opcode)
94+ // }
95+ // }
96+ // return adapter
97+ // }
98+ // ]
99+ // }
100100
0 commit comments