@@ -28,69 +28,69 @@ 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- // 插入的字节码,方法的执行顺序visitAnnotation->onMethodEnter->onMethodExit
73- ' MethodVisitor' : {
74- MethodVisitor methodVisitor, int access, String name, String desc, String className ->
75- AutoMethodVisitor adapter = new AutoMethodVisitor (methodVisitor, access, name, desc, className) {
76- @Override
77- protected void onMethodEnter () {
78- super . onMethodEnter();
79- if (" testOverride" . equals(name))
80- {
81- methodVisitor. visitLdcInsn(name)
82- methodVisitor. visitLdcInsn(" ========start=========" )
83- methodVisitor. visitMethodInsn(Opcodes . INVOKESTATIC , " android/util/Log" , " e" , " (Ljava/lang/String;Ljava/lang/String;)I" , false )
84- }
85- }
86-
87- @Override
88- protected void onMethodExit (int opcode ) {
89- super . onMethodExit(opcode)
90- }
91- }
92- return adapter
93- }
94- ]
95- }
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+ // //插入的字节码,方法的执行顺序visitAnnotation->onMethodEnter->onMethodExit
73+ // 'MethodVisitor': {
74+ // MethodVisitor methodVisitor, int access, String name, String desc, String className ->
75+ // AutoMethodVisitor adapter = new AutoMethodVisitor(methodVisitor, access, name, desc, className) {
76+ // @Override
77+ // protected void onMethodEnter() {
78+ // super.onMethodEnter();
79+ // if("testOverride".equals(name))
80+ // {
81+ // methodVisitor.visitLdcInsn(name)
82+ // methodVisitor.visitLdcInsn("========start=========")
83+ // methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, "android/util/Log", "e", "(Ljava/lang/String;Ljava/lang/String;)I", false)
84+ // }
85+ // }
86+ //
87+ // @Override
88+ // protected void onMethodExit(int opcode) {
89+ // super.onMethodExit(opcode)
90+ // }
91+ // }
92+ // return adapter
93+ // }
94+ // ]
95+ // }
9696
0 commit comments