我正在将项目构建从ANT移植到Gradle。除了混淆部分,一切都已完成,build.xml
中的混淆任务如下:
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="${ant.yguard.path}"/>
<target name="obfuscate-no-test" depends="no-test-jar">
<yguard>
<inoutpairs>
<fileset dir="${dir.dist}">
<include name="**/*.jar"/>
<exclude name="**/*_obf.jar"/>
<exclude name="**/*-doc.jar"/>
</fileset>
</inoutpairs>
<externalclasses>
<path refid="path.lib.biz"/>
<path refid="path.lib.share"/>
<path refid="path.lib.web"/>
</externalclasses>
<rename logfile="${rename.log}">
<property name="naming-scheme" value="best"/>
<keep>
<class classes="none" fields="none" methods="none">
<patternset>
<include name="com.payeshgaran.framework.internal.**.*"/>
</patternset>
</class>
<class classes="public" fields="protected" methods="protected">
<patternset>
<include name="com.payeshgaran.framework.**.*"/>
<exclude name="com.payeshgaran.framework.internal.**.*"/>
</patternset>
</class>
</keep>
<adjust replacecontent="true">
<include name="META-INF/*.tld"/>
</adjust>
</rename>
</yguard>
</target>
为了将其移植到gradle我做了这个:
task obfuscate(dependsOn: [":ext:build", ":biz:build", ":web:build"]) {
ant.taskdef(name: "yguard",
classname: "com.yworks.yguard.YGuardTask",
classpath: "$rootProject.projectDir/lib/ant/yguard-2.5.1.jar")
ant.yguard() {
inoutpairs {
fileset(dir: distFolder) {
include(name: "**/*.jar")
exclude(name: "**/*_obf.jar")
exclude(name: "**/*-doc.jar")
}
}
externalClasses {
fileset(dir: libsFolder) {
include(name: '**/*.jar')
}
}
rename(logFile: "$distFolder/rename.log") {
property(name: "naming-scheme", value: "best")
keep() {
}
adjust(replaceContent: "true") {
include(name: "META-INF/*.tld")
}
}
}
}
除非我无法定义class
对象(在keep
对象内)导致其在groovy中保留一个单词,否则一切顺利。
我能为此做些什么?
答案 0 :(得分:3)
尝试:
keep {
'class'( classes:"none", fields:"none", methods:"none" ) {
...
}
}