Skip to content

Commit 72f4789

Browse files
author
Vens Chen
committed
update
1 parent 0ab03e9 commit 72f4789

File tree

3 files changed

+87
-94
lines changed

3 files changed

+87
-94
lines changed

app/build.gradle

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -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

plugin/build.gradle

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'groovy'
22
apply plugin: 'java'//导入java插件用于,编译打包我们的插件
3-
apply plugin: 'maven'//maven插件,用于上传插件到仓库
3+
//apply plugin: 'maven'//maven插件,用于上传插件到仓库
44

5-
//// JitPack Maven
6-
//apply plugin: 'com.github.dcendents.android-maven'
7-
//// Your Group
8-
//group='com.github.chenthreetrees'
5+
// JitPack Maven
6+
apply plugin: 'com.github.dcendents.android-maven'
7+
// Your Group
8+
group='com.github.chenthreetrees'
99

1010
compileGroovy {
1111
sourceCompatibility = 1.7
@@ -26,16 +26,16 @@ repositories {
2626
mavenCentral()
2727
}
2828

29-
group='com.threetrees.plugin'
30-
version='1.0.0'
31-
32-
//uploadArchives 类型是upload,这个task不是'maven'创建的
33-
//而是'maven'定义了一个rule,而后由我们自己创建的
34-
uploadArchives{
35-
//本地仓库的一种
36-
repositories{
37-
mavenDeployer {
38-
repository(url: uri('../repo'))
39-
}
40-
}
41-
}
29+
//group='com.threetrees.plugin'
30+
//version='1.0.0'
31+
//
32+
////uploadArchives 类型是upload,这个task不是'maven'创建的
33+
////而是'maven'定义了一个rule,而后由我们自己创建的
34+
//uploadArchives{
35+
// //本地仓库的一种
36+
// repositories{
37+
// mavenDeployer {
38+
// repository(url: uri('../repo'))
39+
// }
40+
// }
41+
//}

plugin/src/main/groovy/com/threetrees/plugin/TtreePlugin.groovy

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class TtreePlugin implements Plugin<Project> {
4444
String methodName = map.get("MethodName")
4545
String methodDes = map.get("MethodDes")
4646
boolean override = false
47-
boolean intercept = false
4847
// 全类名
4948
if (!TextUtil.isEmpty(className)){
5049
className = TextUtil.changeClassNameSeparator(className)
@@ -59,19 +58,13 @@ class TtreePlugin implements Plugin<Project> {
5958
override = map.get("Override")
6059
}
6160

62-
if(map.containsKey("Intercept"))
63-
{
64-
intercept = map.get("Intercept")
65-
}
66-
6761
AutoClassFilter classFilter = new AutoClassFilter()
6862
classFilter.setContainName(containName)
6963
classFilter.setClassName(className)
7064
classFilter.setInterfaceName(interfaceName)
7165
classFilter.setMethodName(methodName)
7266
classFilter.setMethodDes(methodDes)
7367
classFilter.setOverride(override)
74-
classFilter.setIntercept(intercept)
7568
Controller.addClassFilter(classFilter)
7669

7770
Logger.info('应用传递过来的数据->' + '\n-containName:' + containName + '\n-className:' + className +

0 commit comments

Comments
 (0)