@@ -31,70 +31,66 @@ dependencies {
3131 compile project(" :pluginutil" )
3232}
3333
34- buildscript {
35- repositories {
36- maven {
37- url uri(' ../repo' )
38- }
39- }
40- dependencies {
41- classpath ' com.threetrees.plugin:plugin:1.0.0'
42- }
43- }
44-
45- apply plugin : ' ttreeplugin'
46-
47-
48-
49-
50-
51- import com.threetrees.plugin.asm.AutoMethodVisitor
52- import org.objectweb.asm.MethodVisitor
53- import org.objectweb.asm.Opcodes
54-
55- ttree {
56- isDebug = true
57- // 具体配置
58- matchData = [
59- ' AnnotationPath' : ' com.threetree.ttreeplugin.annotation' ,
60- ' AnnotationReceiver' : ' com.threetree.ttreeplugin.MyReceiver' ,
61- ' ClassReceiver' : ' com.threetree.ttreeplugin.MyReceiver' ,
62- ' ClassFilter' : [
63- // 根据类型匹配
64- [' ClassName' : ' com/threetree/ttreeplugin/MainActivity' ,
65- ' MethodName' : ' testClassName' , ' MethodDes' : ' ()V' ],
66- // 根据关键字匹配
67- [' ContainName' : ' Activity' ,
68- ' MethodName' : ' testContainName' , ' MethodDes' : ' (Ljava/lang/String;)V' ],
69- // 根据接口名匹配
70- [' InterfaceName' : ' android/view/View$OnClickListener' ,
71- ' MethodName' : ' onClick' , ' MethodDes' : ' (Landroid/view/View;)V' ],
72- // 根据类型匹配
73- [' ClassName' : ' com/threetree/ttreeplugin/MainActivity' ,
74- ' MethodName' : ' testOverride' , ' MethodDes' : ' ()V' , ' Override' : true ]
75- ],
76- // 插入的字节码,方法的执行顺序visitAnnotation->onMethodEnter->onMethodExit
77- ' MethodVisitor' : {
78- MethodVisitor methodVisitor, int access, String name, String desc ->
79- AutoMethodVisitor adapter = new AutoMethodVisitor (methodVisitor, access, name, desc) {
80- @Override
81- protected void onMethodEnter () {
82- super . onMethodEnter();
83- if (" testOverride" . equals(name))
84- {
85- methodVisitor. visitLdcInsn(name)
86- methodVisitor. visitLdcInsn(" ========start=========" )
87- methodVisitor. 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- }
34+ // buildscript {
35+ // repositories {
36+ // maven {
37+ // url uri('../repo')
38+ // }
39+ // }
40+ // dependencies {
41+ // classpath 'com.threetrees.plugin:plugin:1.0.0'
42+ // }
43+ // }
44+ //
45+ // apply plugin: 'ttreeplugin'
46+ //
47+ // import com.threetrees.plugin.asm.AutoMethodVisitor
48+ // import org.objectweb.asm.MethodVisitor
49+ // import org.objectweb.asm.Opcodes
50+ //
51+ // ttree {
52+ // isDebug = true
53+ // //具体配置
54+ // matchData = [
55+ // 'AnnotationPath' : 'com.threetree.ttreeplugin.annotation',
56+ // 'AnnotationReceiver' : 'com.threetree.ttreeplugin.MyReceiver',
57+ // 'ClassReceiver' : 'com.threetree.ttreeplugin.MyReceiver',
58+ // 'ClassFilter' : [
59+ // //根据类型匹配
60+ // ['ClassName' : 'com/threetree/ttreeplugin/MainActivity',
61+ // 'MethodName': 'testClassName', 'MethodDes': '()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 ->
75+ // AutoMethodVisitor adapter = new AutoMethodVisitor(methodVisitor, access, name, desc) {
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+ // }
10096
0 commit comments