[Home]Ant/MinimalJarSample

Robo Home | Ant | Changes | Preferences | AllPages

You can get the <pack> task here: http://sadun-util.sourceforge.net/pack.html

You can get yguard, a free obfuscator, here: http://www.yworks.com/en/products_yguard_about.htm

Using both will shrink your Jar file by quite a bit. Even if you're including source code with your bot, obfuscating your robot will make your .class files much smaller. The only downside is that if your robot throws an exception, the stack traces are giberish, like NullPointerException in class davidalves/A/B/A.class (unknown source)

--David Alves

<?xml version="1.0"?>
<!-- ====================================================================== 

     Phoenix
                   
     by David Alves                                                                

     ====================================================================== -->


<project name="Phoenix" default="Phoenix">
	
	<taskdef name="obfuscate" 
		classname="com.yworks.yguard.ObfuscatorTask" 
		classpath="yguard.jar"/>
	<taskdef name="pack"
		classname="org.sadun.util.ant.Pack"
		classpath="pack.jar"/>
	
	<description>Phoenix</description>
	
	<target name="Phoenix" description="Make Phoenix jar">
		<delete file="phoenix.jar" />
		<delete file="phoenix-obf.jar" />
		
		<pack classes="davidalves.Phoenix" targetjar="phoenix.jar" excludepkg="java,javax,sun,robocode">
			<classpath path="c:/phoenix"/>
			<classpath location="c:/robocode/clean_install/robocode.jar"/>
			<resource name="davidalves/Phoenix.properties"/>
		</pack>
		
		<java fork="yes" jar="/robocode/codesize.jar">
			<arg value="c:/phoenix/phoenix.jar" />
		</java>
		
		<obfuscate replaceclassnamestrings="true" logfile="obf.txt">
			<inoutpair in="phoenix.jar" out="phoenix-obf.jar"/>
			<expose>
				<class name="davidalves.Phoenix" methods="public" fields="none" />
			</expose>
			<externalclasses>
				<pathelement location="/robocode/clean_install/robocode.jar"/>
			</externalclasses>
		</obfuscate>
	</target>
	
	<target name="backup" description="full backup">
		<tstamp/>
		<jar compress="true" destfile="phoenix-backup${DSTAMP}-${TSTAMP}.jar" manifest="MANIFEST.MF">
			<fileset dir=".">
				<include name="davidalves/**/*.*"/>
			</fileset>
		</jar>
	</target>
</project>

Robo Home | Ant | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited July 12, 2006 0:45 EST by David Alves (diff)
Search: