Skip to content

Commit b3ac92d

Browse files
committed
fix bug
1 parent d6b4e44 commit b3ac92d

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,20 @@ public class ObfPlugin implements Plugin<Project> {
3131
def action = new Action<Task>() {
3232
@Override
3333
void execute(Task task) {
34-
DexMergingTask dexMergingTask = task
35-
def file = dexMergingTask.outputDir
36-
File finalFile
37-
if (file instanceof File) {
38-
finalFile = file
39-
} else if (file instanceof DefaultFilePropertyFactory.DefaultDirectoryVar) {
40-
DefaultFilePropertyFactory.DefaultDirectoryVar defaultDirectoryVar = dexMergingTask.outputDir
41-
finalFile = defaultDirectoryVar.asFile.get()
42-
} else {
43-
throw new RuntimeException("BlackObfuscator not support the gradle version!")
34+
task.getOutputs().getFiles().collect().each() { element ->
35+
def file = new File(element.toString())
36+
ObfDex.obf(file.getAbsolutePath(),
37+
sObfuscatorExtension.depth, sObfuscatorExtension.obfClass)
4438
}
45-
ObfDex.obf(finalFile.getAbsolutePath(),
46-
sObfuscatorExtension.depth, sObfuscatorExtension.obfClass)
4739
}
4840
}
4941
List<Task> tasks = new ArrayList<>()
50-
List<Task> tasks2 = new ArrayList<>()
5142
addTask("mergeDexRelease", tasks)
5243
addTask("mergeLibDexDebug", tasks)
5344
addTask("mergeProjectDexDebug", tasks)
54-
55-
addTask("transformDexArchiveWithDexMergerForDebug", tasks2)
56-
addTask("transformDexArchiveWithDexMergerForRelease", tasks2)
45+
addTask("transformDexArchiveWithDexMergerForDebug", tasks)
46+
addTask("transformDexArchiveWithDexMergerForRelease", tasks)
47+
addTask("minifyReleaseWithR8", tasks)
5748

5849
if (android != null) {
5950
android.productFlavors.all(new Action<ProductFlavor>() {
@@ -66,8 +57,10 @@ public class ObfPlugin implements Plugin<Project> {
6657
addTask("mergeLibDex${p}Debug", tasks)
6758
addTask("mergeProjectDex${p}Debug", tasks)
6859

69-
addTask("transformDexArchiveWithDexMergerFor${p}Debug", tasks2)
70-
addTask("transformDexArchiveWithDexMergerFor${p}Release", tasks2)
60+
addTask("transformDexArchiveWithDexMergerFor${p}Debug", tasks)
61+
addTask("transformDexArchiveWithDexMergerFor${p}Release", tasks)
62+
63+
addTask("minify${p}ReleaseWithR8", tasks)
7164
}
7265
}
7366
})
@@ -76,22 +69,7 @@ public class ObfPlugin implements Plugin<Project> {
7669
for (Task task : tasks) {
7770
task.doLast(action)
7871
}
79-
80-
def action2 = new Action<Task>() {
81-
@Override
82-
void execute(Task task) {
83-
task.getOutputs().getFiles().collect().each() { element ->
84-
def file = new File(element.toString())
85-
ObfDex.obf(file.getAbsolutePath(),
86-
sObfuscatorExtension.depth, sObfuscatorExtension.obfClass)
87-
}
88-
}
89-
}
90-
for (Task task : tasks2) {
91-
task.doLast(action2)
92-
}
93-
94-
if (tasks2.isEmpty() && tasks.isEmpty()) {
72+
if (tasks.isEmpty()) {
9573
System.err.println("This gradle version is not applicable. Please submit issues in https://github.com/CodingGay/BlackObfuscator-ASPlugin")
9674
}
9775
}

0 commit comments

Comments
 (0)