Robo Home | Ant | Changes | Preferences | AllPages

The way I package is to manually edit the Phoenix.properties file to have the latest version number. This is then parsed by the ant build file to generate a jar with the right name.

Tools used by this build file:

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

     Phoenix build file

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

<project name="Phoenix" default="Phoenix" basedir=".">
	<property name="robot.properties.file" location="davidalves/Phoenix.properties" />
	<property name="team.properties.file" location="davidalves/PhoenixTeam.team" />
	<property name="robot.name" value="Phoenix" />
	<property name="robocode.jar" location="c:/robocode/dev/robocode.jar" />
	<taskdef name="obfuscate" 
	<taskdef name="pack"
	<!-- Load version number from Phoenix.properties file -->
	<property file="${robot.properties.file}" />
	<target name="Phoenix" description="Make Phoenix jar">
		<!-- Make date stamp -->
		<property name="backup.file" location="${robot.name}_${robot.version}_${DSTAMP}.jar" />
		<property name="release.file" location="${robot.classname}_${robot.version}.jar" />
		<property name="temp.file" location="${robot.name}_temp.jar" />
		<delete file="${backup.file}" failonerror="false" />
		<delete file="${release.file}" failonerror="false" />
		<delete file="${temp.file}" failonerror="false" />
		<jar duplicate="add" basedir="." destfile="${backup.file}" compress="true">
			<include name="davidalves/**/*.java" />
			<include name="davidalves/**/*.class" />
			<include name="${robot.properties.file}" />
			<include name="${team.properties.file}" />
		<!-- "pack" task selects only the minimal set of classes needed to run the bot. 
			 This can also be done with the "classfileset" task from ant-contrib -->
		<pack classes="${robot.classname}" targetjar="${temp.file}" excludepkg="java,javax,sun,robocode">
			<classpath path="." />
			<classpath location="${robocode.jar}" />
			<resource name="davidalves/Phoenix.properties" />
		<!-- Print codesize-->
		<java fork="yes" jar="/robocode/codesize.jar">
			<arg value="${temp.file}" />
		<!-- Obfuscate release jar -->
		<obfuscate replaceclassnamestrings="true" logfile="obf.txt">
			<inoutpair in="${temp.file}" out="${release.file}" />
				<class name="davidalves.Phoenix" methods="public" fields="none" />
				<pathelement location="${robocode.jar}"/>

Robo Home | Ant | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited October 18, 2007 17:23 EST by David Alves (diff)