I'm trying to invoke yGuard Ant task from Gradle:
ant.taskdef(name:'yguard', classname:'com.yworks.yguard.YGuardTask', classpath: '../yguard/yguard-2.9.2.jar;../yguard/retroguard-2.9.2.jar;../yguard/guava-28.1-android.jar;../yguard/asm-7.2.jar')
ant.yguard {
inoutpair(in: 'in.jar', out: 'out.jar')
attribute(name:'Deprecated, SourceFile, LineNumberTable, LocalVariableTable, LocalVariableTypeTable')
rename(mainclass:"com.....z.Z",logfile:"obfuscation.log",replaceClassNameStrings:"true") {
keep {
class(implements:"java.io.Serializable",classes:"private",methods:"private",fields:"private") {
patternset {
include name:"org.**.*"
include name:"com.google.**.*"
include name:"com.sun.**.*"
// ...
}
}
}
}
}
I'm quite used to invoke Ant from Gradle, but here I'm stuck on the tag name which is named <class .../>
. Of course Groovy confused with the getClass() method.
I've tried the following alternative (as suggested here: Gradle - how to run ant task with "-" in name):
ant.class
=> same
ant."class"
=> don't know what it does, but doesn't work :)
But it is still confusing with getClass() method I think
of course, there is the following solution:
- use
ant.importBuild
instead, to write XML instead of groovy scripts, but it would be too easy ;) And I'd would really like to stay in groovy/gradle DSL if possible - I could use yGuard gradle plugin instead, but I encountered problems
The example with yGuard is just an example. I would really love to understand which mechanism is used underneath, and how to enforce the behavior I want (Groovy is so powerful, I'm pretty sure, there is a way)