-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from BryanSharp/easy_jar_modify-0621
1.2.7 release modify jar more easily
- Loading branch information
Showing
7 changed files
with
117 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
language: java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
maven { | ||
url uri('../snapshotRepo') | ||
} | ||
} | ||
dependencies { | ||
classpath 'com.bryansharp:hibeaver:1.2.7-SNAPSHOT'//this is the local version | ||
} | ||
} | ||
apply plugin: 'hiBeaver' | ||
import com.bryansharp.gradle.hibeaver.utils.MethodLogAdapter | ||
import org.objectweb.asm.ClassVisitor | ||
import org.objectweb.asm.MethodVisitor | ||
import org.objectweb.asm.Opcodes | ||
|
||
//or you can import like bellow: | ||
//import org.objectweb.asm.* | ||
hiBeaver { | ||
//this will determine the name of this hibeaver transform, no practical use. | ||
hiBeaverModifyName = 'myHibeaverTest' | ||
//turn this on to make it print help content, default value is true | ||
showHelp = true | ||
//this flag will decide whether the log of the modifying process be printed or not, default value is false | ||
keepQuiet = false | ||
//this is a kit feature of the plugin, set it true to see the time consume of this build | ||
watchTimeConsume = false | ||
|
||
//this is the most important part | ||
modifyMatchMaps = [ | ||
'com.xiaomi.mipush.sdk.u' : [ | ||
// you can use javap -s command to get the description of one method | ||
['methodName': 'a', 'methodDesc': '(Lorg/apache/thrift/a;Lcom/xiaomi/xmpush/thrift/a;ZLcom/xiaomi/xmpush/thrift/r;)V', 'adapter': { | ||
ClassVisitor cv, int access, String name, String desc, String signature, String[] exceptions -> | ||
MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, signature, exceptions); | ||
MethodVisitor adapter = new MethodLogAdapter(methodVisitor) { | ||
@Override | ||
void visitCode() { | ||
super.visitCode(); | ||
methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); | ||
methodVisitor.visitVarInsn(Opcodes.ALOAD, 2); | ||
methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, MethodLogAdapter.className2Path("bruce.com.testhibeaver.MainActivity"), "hookXM", "(Ljava/lang/Object;Ljava/lang/Object;)V"); | ||
} | ||
} | ||
return adapter; | ||
}] | ||
], | ||
'*Activity|*Receiver|!android*': [ | ||
['methodName': 'on**', 'methodDesc': null, 'adapter': { | ||
ClassVisitor cv, int access, String name, String desc, String signature, String[] exceptions -> | ||
MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, signature, exceptions); | ||
MethodVisitor adapter = new MethodLogAdapter(methodVisitor) { | ||
@Override | ||
void visitCode() { | ||
super.visitCode(); | ||
methodVisitor.visitLdcInsn(desc); | ||
methodVisitor.visitLdcInsn(name); | ||
methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, "bruce/com/testhibeaver/MainActivity", "hookXM", "(Ljava/lang/Object;Ljava/lang/Object;)V"); | ||
} | ||
} | ||
return adapter; | ||
}] | ||
] | ||
, | ||
'r:.*D[a-zA-Z]*Client' : [ | ||
['methodName': 'on**', 'methodDesc': null, 'adapter': { | ||
ClassVisitor cv, int access, String name, String desc, String signature, String[] exceptions -> | ||
MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, signature, exceptions); | ||
MethodVisitor adapter = new MethodLogAdapter(methodVisitor) { | ||
@Override | ||
void visitCode() { | ||
super.visitCode(); | ||
methodVisitor.visitLdcInsn(desc); | ||
methodVisitor.visitLdcInsn(name); | ||
methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, "bruce/com/testhibeaver/MainActivity", "hookXM", "(Ljava/lang/Object;Ljava/lang/Object;)V"); | ||
} | ||
} | ||
return adapter; | ||
}] | ||
] | ||
] | ||
modifyTasks = ["${rootDir.absolutePath}/MiPush_SDK_Client_3_2_2.jar": modifyMatchMaps] | ||
} |