ProGuard和Eclipse融合

本文提供了一个完整的 Ant build.xml 文件示例,用于 Eclipse 中 J2SE 应用程序的编译、打包及代码压缩、优化与混淆。通过这个文件,你可以一次性完成从源代码到最终发布版的所有步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  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.

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script>

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值