现在的位置: 首页 > 综合 > 正文

ProGuard和Eclipse融合

2012年11月11日 ⁄ 综合 ⁄ 共 1168字 ⁄ 字号 评论关闭

  If you are building J2SE apps with Eclipse and want to use ProGuard to compress, optimise or obfuscate your code you’ll need to create an Ant build.xml file to do this. I found various bits of help on the internet explaining parts of the build.xml file, but couldn’t find anywhere that gave the complete build.xml to do the full compile, jar and proguard steps.

Here is the full build.xml I cobbled together to do all three:
<?xml version="1.0" ?>

<project default="main">

<taskdef resource="proguard/ant/task.properties"
classpath="D:/apps/proguard4.0.1/lib/proguard.jar" />

<target name="main" depends="compile, jar, obfuscate"
description="Create project">
<echo>Creating project.</echo>
</target>

<target name="compile" description="Compile target">
<javac srcdir="src" destdir="bin"/>
</target>

<target name="jar" description="Jar target">
<jar jarfile="PhotoStamper_debug.jar"
basedir="bin" includes="*.class">
<manifest>
<attribute name="Main-Class" value="PhotoStamper" />
</manifest>
</jar>
</target>

<target name="obfuscate" depends="jar"
description="Obfuscate compiled classes">
<proguard>
-libraryjars "${java.home}/lib/rt.jar"
-injars PhotoStamper_debug.jar
-outjars PhotoStamper.jar
-keep public class PhotoStamper {
public static void main(java.lang.String[]);
}
</proguard>
</target>

</project>

抱歉!评论已关闭.