diff --git a/plugin/build.gradle b/plugin/build.gradle index d7de75d..f003331 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -11,7 +11,7 @@ dependencies { implementation gradleApi() //groovy sdk implementation localGroovy() - implementation "com.github.CodingGay.BlackObfuscator:dex-tools:2.0" + implementation "com.github.CodingGay.BlackObfuscator:dex-tools:2.1" } repositories { diff --git a/plugin/src/main/groovy/top/niunaijun/blackobfuscator/BlackObfuscatorExtension.groovy b/plugin/src/main/groovy/top/niunaijun/blackobfuscator/BlackObfuscatorExtension.groovy index 52b7910..3a26cd7 100644 --- a/plugin/src/main/groovy/top/niunaijun/blackobfuscator/BlackObfuscatorExtension.groovy +++ b/plugin/src/main/groovy/top/niunaijun/blackobfuscator/BlackObfuscatorExtension.groovy @@ -5,6 +5,7 @@ class BlackObfuscatorExtension { boolean enabled = false int depth = 1 String[] obfClass = [] + String[] blackClass = [] BlackObfuscatorExtension(Project project) { @@ -17,6 +18,7 @@ class BlackObfuscatorExtension { "enabled=" + enabled + ", depth=" + depth + ", obfClass=" + Arrays.toString(obfClass) + + ", blackClass=" + Arrays.toString(blackClass) + '}'; } } \ No newline at end of file diff --git a/plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy b/plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy index 370e852..005a5fb 100644 --- a/plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy +++ b/plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy @@ -34,7 +34,7 @@ public class ObfPlugin implements Plugin { task.getOutputs().getFiles().collect().each() { element -> def file = new File(element.toString()) ObfDex.obf(file.getAbsolutePath(), - sObfuscatorExtension.depth, sObfuscatorExtension.obfClass) + sObfuscatorExtension.depth, sObfuscatorExtension.obfClass, sObfuscatorExtension.blackClass) } } } diff --git a/plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java b/plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java index d03e0d8..2365ecc 100644 --- a/plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java +++ b/plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java @@ -19,7 +19,7 @@ * 此处无Bug */ public class ObfDex { - public static void obf(String dir, int depth, String[] obfClass) { + public static void obf(String dir, int depth, String[] obfClass, String[] blackClass) { File file = new File(dir); if (file.isDirectory()) { File[] files = file.listFiles(); @@ -27,17 +27,17 @@ public static void obf(String dir, int depth, String[] obfClass) { return; for (File input : files) { if (input.isFile()) { - handleDex(input, depth, obfClass); + handleDex(input, depth, obfClass, blackClass); } else { - obf(input.getAbsolutePath(), depth, obfClass); + obf(input.getAbsolutePath(), depth, obfClass, blackClass); } } } else { - handleDex(file, depth, obfClass); + handleDex(file, depth, obfClass, blackClass); } } - private static void handleDex(File input, int depth, String[] obfClass) { + private static void handleDex(File input, int depth, String[] obfClass, String[] blackClass) { if (!input.getAbsolutePath().endsWith(".dex")) return; File tempJar = null; @@ -47,7 +47,7 @@ private static void handleDex(File input, int depth, String[] obfClass) { tempJar = new File(input.getParent(), System.currentTimeMillis() + "obf" + input.getName() + ".jar"); splitDex = new File(input.getParent(), System.currentTimeMillis() + "split" + input.getName() + ".dex"); obfDex = new File(input.getParent(), System.currentTimeMillis() + "obf" + input.getName() + ".dex"); - long l = DexLib2Utils.splitDex(input, splitDex, Arrays.asList(obfClass)); + long l = DexLib2Utils.splitDex(input, splitDex, Arrays.asList(obfClass), Arrays.asList(blackClass)); if (l <= 0) { System.out.println("Obfuscator Class not found"); return;