Difference between revisions of "User:Nat/Ant Build File"

From Robowiki
Jump to navigation Jump to search
(my ant build file I'm using now)
 
m
 
(One intermediate revision by the same user not shown)
Line 36: Line 36:
  
 
== XML File ==
 
== XML File ==
 
+
Because color make you memorization better by 72%, so... (but I can't disabled the auto line break TT)
<pre>
+
<!-- Don't edit below unless you know what you are doing, I have no backup of that code with formatting! -->
<?xml version="1.0" encoding="utf-8"?>
+
<span style='font-family:"Courier New", courier, monospace;display:block;line-height: 1em; border: 1px dashed rgb(47, 111, 171); padding: 1em;'> <span style="color: #c60"><span style="color: #f00">&lt;?xml&nbsp;<span style="color: #606">version</span><span style="color: #000">=</span><span style="color: #00f">&quot;1.0&quot;</span>&nbsp;<span style="color: #606">encoding</span><span style="color: #000">=</span><span style="color: #00f">&quot;utf-8&quot;</span>&nbsp;?&gt;</span></span><br /> <span style="color: #090">&lt;!--&nbsp;======================================================<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ANT&nbsp;build&nbsp;file<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nat&nbsp;Pavasant<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;======================================================<br /> &nbsp;<br /> &nbsp;Directory&nbsp;structure:<br /> &nbsp;&nbsp;-&nbsp;/bin&nbsp;-&nbsp;this&nbsp;will&nbsp;store&nbsp;all&nbsp;of&nbsp;classes&nbsp;files<br /> &nbsp;&nbsp;-&nbsp;/src&nbsp;-&nbsp;this&nbsp;will&nbsp;store&nbsp;all&nbsp;of&nbsp;source&nbsp;files<br /> &nbsp;&nbsp;-&nbsp;/resource&nbsp;-&nbsp;contain&nbsp;all&nbsp;the&nbsp;resources&nbsp;you&nbsp;want&nbsp;to&nbsp;include&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;.jar&nbsp;in&nbsp;the&nbsp;same&nbsp;structure<br /> &nbsp;&nbsp;-&nbsp;/backups&nbsp;-&nbsp;contain&nbsp;each&nbsp;and&nbsp;every&nbsp;build&nbsp;of&nbsp;your&nbsp;code.<br /> &nbsp;&nbsp;<br /> &nbsp;Dependancies:<br /> &nbsp;&nbsp;-&nbsp;Pack&nbsp;task&nbsp;(http://sadun-util.sourceforge.net/pack.html)<br /> &nbsp;&nbsp;-&nbsp;yGuard&nbsp;Obfuscator&nbsp;(http://www.yworks.com/en/products_yguard_about.htm)<br /> &nbsp;&nbsp;-&nbsp;CodeSize&nbsp;version&nbsp;1.0&nbsp;(version&nbsp;1.1&nbsp;come&nbsp;with&nbsp;robocode&nbsp;now&nbsp;doesn't&nbsp;have&nbsp;valid&nbsp;entry&nbsp;point)<br /> &nbsp;<br /> &nbsp;Configuration:<br /> &nbsp;&nbsp;-&nbsp;basedir&nbsp;-&nbsp;in&nbsp;<span style="color: #c60">&lt;project&gt;</span>&nbsp;tag&nbsp;-&nbsp;must&nbsp;set&nbsp;to&nbsp;your&nbsp;working&nbsp;directory&nbsp;that<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contains&nbsp;the&nbsp;structure<br /> &nbsp;&nbsp;-&nbsp;In&nbsp;task&nbsp;'init'<br /> &nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;robot.name&nbsp;-&nbsp;robot&nbsp;classname<br /> &nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;robot.package&nbsp;-&nbsp;robot&nbsp;package&nbsp;name<br /> &nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;robot.propertiesfile&nbsp;-&nbsp;path&nbsp;to&nbsp;property&nbsp;file&nbsp;to&nbsp;created<br /> &nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;...<br /> &nbsp;&nbsp;<br /> &nbsp;&nbsp;Credit:<br /> &nbsp;&nbsp;&nbsp;-&nbsp;David&nbsp;Alves<br /> &nbsp;&nbsp;&nbsp;-&nbsp;Hexkid<br /> <br /> =======================================================&nbsp;--&gt;</span><br /> <span style="color: #c60">&lt;project&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;Robot&quot;</span>&nbsp;<span style="color: #606">default</span><span style="color: #000">=</span><span style="color: #00f">&quot;build&quot;</span>&nbsp;<span style="color: #606">basedir</span><span style="color: #000">=</span><span style="color: #00f">&quot;.&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;description&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00f">Build&nbsp;File</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/description&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;define&nbsp;a&nbsp;task&nbsp;use&nbsp;in&nbsp;this&nbsp;build&nbsp;file&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;taskdef&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;yguard&quot;</span>&nbsp;<span style="color: #606">classname</span><span style="color: #000">=</span><span style="color: #00f">&quot;com.yworks.yguard.YGuardTask&quot;</span>&nbsp;<span style="color: #606">classpath</span><span style="color: #000">=</span><span style="color: #00f">&quot;./yguard.jar&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;taskdef&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;pack&quot;</span>&nbsp;<span style="color: #606">classname</span><span style="color: #000">=</span><span style="color: #00f">&quot;org.sadun.util.ant.Pack&quot;</span>&nbsp;<span style="color: #606">classpath</span><span style="color: #000">=</span><span style="color: #00f">&quot;./pack.jar&quot;</span>&nbsp;/&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;Initialize&nbsp;the&nbsp;config,&nbsp;all&nbsp;properties&nbsp;must&nbsp;be&nbsp;here&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;target&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;init&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Initialize&nbsp;properties&nbsp;to&nbsp;build&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;tstamp&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;configure&nbsp;time&nbsp;string&nbsp;use&nbsp;for&nbsp;backup&nbsp;version&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;format&nbsp;<span style="color: #606">property</span><span style="color: #000">=</span><span style="color: #00f">&quot;timestamp&quot;</span>&nbsp;<span style="color: #606">pattern</span><span style="color: #000">=</span><span style="color: #00f">&quot;yyyyMMdHHmmss&quot;</span>&nbsp;<span style="color: #606">locale</span><span style="color: #000">=</span><span style="color: #00f">&quot;en,US&quot;</span>&nbsp;<span style="color: #606">timezone</span><span style="color: #000">=</span><span style="color: #00f">&quot;UTC&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/tstamp&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;Start&nbsp;configuration&nbsp;setting&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;robot.name&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;Your&nbsp;Robot&nbsp;Name&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;robot.package&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;Your&nbsp;Package&nbsp;Name&quot;</span>&nbsp;/&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;Set&nbsp;the&nbsp;path&nbsp;to&nbsp;your&nbsp;properties&nbsp;file&nbsp;inside&nbsp;.jar,&nbsp;please&nbsp;make&nbsp;sure&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;the&nbsp;specific&nbsp;directory&nbsp;is&nbsp;available&nbsp;under&nbsp;./resource/&nbsp;directory&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;robot.propertiesfile&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;Your&nbsp;package&nbsp;name/${robot.name}.properties&quot;</span>&nbsp;/&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;Create&nbsp;the&nbsp;property&nbsp;file&nbsp;that&nbsp;describes&nbsp;this&nbsp;robot&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;propertyfile&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;resource/${robot.propertiesfile}&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;entry&nbsp;<span style="color: #606">key</span><span style="color: #000">=</span><span style="color: #00f">&quot;robot.description&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;entry&nbsp;<span style="color: #606">key</span><span style="color: #000">=</span><span style="color: #00f">&quot;robot.java.source.included&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;false&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;entry&nbsp;<span style="color: #606">key</span><span style="color: #000">=</span><span style="color: #00f">&quot;robocode.version&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;1.7.1.2&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;entry&nbsp;<span style="color: #606">key</span><span style="color: #000">=</span><span style="color: #00f">&quot;robot.version&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;0.1&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;entry&nbsp;<span style="color: #606">key</span><span style="color: #000">=</span><span style="color: #00f">&quot;robot.author.name&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;Your&nbsp;Name&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;entry&nbsp;<span style="color: #606">key</span><span style="color: #000">=</span><span style="color: #00f">&quot;robot.classname&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;${robot.package}.${robot.name}&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/propertyfile&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;resource/${robot.propertiesfile}&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Use&nbsp;the&nbsp;entries&nbsp;from&nbsp;the&nbsp;properties&nbsp;file&nbsp;within&nbsp;this&nbsp;script.&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;robocode.home&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;C:\robocode&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;robocode.jar&quot;</span>&nbsp;<span style="color: #606">location</span><span style="color: #000">=</span><span style="color: #00f">&quot;${robocode.home}/libs/robocode.jar&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;codesize.jar&quot;</span>&nbsp;<span style="color: #606">location</span><span style="color: #000">=</span><span style="color: #00f">&quot;./codesize.jar&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;class.path&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;./bin;${robocode.jar}&quot;</span>&nbsp;/&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;COMPILECLASSNAME&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;COMPILE_WITH_DEBUG&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;off&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;VERBOSE_LEVEL&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;1&quot;</span>&nbsp;/&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;backup.file&quot;</span>&nbsp;<span style="color: #606">location</span><span style="color: #000">=</span><span style="color: #00f">&quot;target/${robot.name}_${robot.version}_${timestamp}.jar&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;release.file&quot;</span>&nbsp;<span style="color: #606">location</span><span style="color: #000">=</span><span style="color: #00f">&quot;target/${robot.classname}_${robot.version}.jar&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;temp.file&quot;</span>&nbsp;<span style="color: #606">location</span><span style="color: #000">=</span><span style="color: #00f">&quot;target/${robot.name}_temp.jar&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/target&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;Clean&nbsp;up&nbsp;the&nbsp;build&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;target&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;clean&quot;</span>&nbsp;<span style="color: #606">depends</span><span style="color: #000">=</span><span style="color: #00f">&quot;init&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Remove&nbsp;the&nbsp;directories&nbsp;containing&nbsp;the&nbsp;classes&nbsp;and&nbsp;the&nbsp;jar&nbsp;file&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;delete&nbsp;<span style="color: #606">dir</span><span style="color: #000">=</span><span style="color: #00f">&quot;bin&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;delete&nbsp;<span style="color: #606">dir</span><span style="color: #000">=</span><span style="color: #00f">&quot;target&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/target&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;target&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;prepare&quot;</span>&nbsp;<span style="color: #606">depends</span><span style="color: #000">=</span><span style="color: #00f">&quot;init&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Create&nbsp;the&nbsp;generated&nbsp;directories&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;mkdir&nbsp;<span style="color: #606">dir</span><span style="color: #000">=</span><span style="color: #00f">&quot;bin&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;mkdir&nbsp;<span style="color: #606">dir</span><span style="color: #000">=</span><span style="color: #00f">&quot;target&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/target&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;target&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;compile&quot;</span>&nbsp;<span style="color: #606">depends</span><span style="color: #000">=</span><span style="color: #00f">&quot;prepare&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Compile&nbsp;the&nbsp;Java&nbsp;classes&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;javac&nbsp;<span style="color: #606">srcdir</span><span style="color: #000">=</span><span style="color: #00f">&quot;src&quot;</span>&nbsp;<span style="color: #606">destdir</span><span style="color: #000">=</span><span style="color: #00f">&quot;bin&quot;</span>&nbsp;<span style="color: #606">classpath</span><span style="color: #000">=</span><span style="color: #00f">&quot;${class.path}&quot;</span>&nbsp;<span style="color: #606">debug</span><span style="color: #000">=</span><span style="color: #00f">&quot;${COMPILE_WITH_DEBUG}&quot;</span>&nbsp;<span style="color: #606">includes</span><span style="color: #000">=</span><span style="color: #00f">&quot;**/*.java&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/target&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;target&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;buildjar&quot;</span>&nbsp;<span style="color: #606">depends</span><span style="color: #000">=</span><span style="color: #00f">&quot;compile&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Make&nbsp;.jar&nbsp;file&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;delete&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;${backup.file}&quot;</span>&nbsp;<span style="color: #606">failonerror</span><span style="color: #000">=</span><span style="color: #00f">&quot;false&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;delete&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;${release.file}&quot;</span>&nbsp;<span style="color: #606">failonerror</span><span style="color: #000">=</span><span style="color: #00f">&quot;false&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;delete&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;${temp.file}&quot;</span>&nbsp;<span style="color: #606">failonerror</span><span style="color: #000">=</span><span style="color: #00f">&quot;false&quot;</span>&nbsp;/&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;jar&nbsp;<span style="color: #606">duplicate</span><span style="color: #000">=</span><span style="color: #00f">&quot;add&quot;</span>&nbsp;<span style="color: #606">destfile</span><span style="color: #000">=</span><span style="color: #00f">&quot;${backup.file}&quot;</span>&nbsp;<span style="color: #606">compress</span><span style="color: #000">=</span><span style="color: #00f">&quot;true&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;fileset&nbsp;<span style="color: #606">dir</span><span style="color: #000">=</span><span style="color: #00f">&quot;bin&quot;</span>&nbsp;<span style="color: #606">includes</span><span style="color: #000">=</span><span style="color: #00f">&quot;**/*.class&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;fileset&nbsp;<span style="color: #606">dir</span><span style="color: #000">=</span><span style="color: #00f">&quot;src&quot;</span>&nbsp;<span style="color: #606">includes</span><span style="color: #000">=</span><span style="color: #00f">&quot;**/*.java&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;fileset&nbsp;<span style="color: #606">dir</span><span style="color: #000">=</span><span style="color: #00f">&quot;resource&quot;</span>&nbsp;<span style="color: #606">includes</span><span style="color: #000">=</span><span style="color: #00f">&quot;**/*&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/jar&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;pack&nbsp;<span style="color: #606">classes</span><span style="color: #000">=</span><span style="color: #00f">&quot;${robot.classname}&quot;</span>&nbsp;<span style="color: #606">targetjar</span><span style="color: #000">=</span><span style="color: #00f">&quot;${temp.file}&quot;</span>&nbsp;<span style="color: #606">excludepkg</span><span style="color: #000">=</span><span style="color: #00f">&quot;java,javax,sun,robocode&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;classpath&nbsp;<span style="color: #606">path</span><span style="color: #000">=</span><span style="color: #00f">&quot;./bin&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;classpath&nbsp;<span style="color: #606">location</span><span style="color: #000">=</span><span style="color: #00f">&quot;${robocode.jar}&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;additionalfileset&nbsp;<span style="color: #606">dir</span><span style="color: #000">=</span><span style="color: #00f">&quot;resource&quot;</span>&nbsp;<span style="color: #606">includes</span><span style="color: #000">=</span><span style="color: #00f">&quot;**/*&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/pack&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;Print&nbsp;codesize--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;java&nbsp;<span style="color: #606">fork</span><span style="color: #000">=</span><span style="color: #00f">&quot;yes&quot;</span>&nbsp;<span style="color: #606">jar</span><span style="color: #000">=</span><span style="color: #00f">&quot;${codesize.jar}&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;arg&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;${temp.file}&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/java&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;Obfuscate&nbsp;release&nbsp;jar&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;yguard&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;inoutpair&nbsp;<span style="color: #606">in</span><span style="color: #000">=</span><span style="color: #00f">&quot;${temp.file}&quot;</span>&nbsp;<span style="color: #606">out</span><span style="color: #000">=</span><span style="color: #00f">&quot;${release.file}&quot;</span>&nbsp;/&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;externalclasses&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;pathelement&nbsp;<span style="color: #606">location</span><span style="color: #000">=</span><span style="color: #00f">&quot;${robocode.jar}&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/externalclasses&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;rename&nbsp;<span style="color: #606">logfile</span><span style="color: #000">=</span><span style="color: #00f">&quot;obfuscate.log&quot;</span>&nbsp;<span style="color: #606">replaceclassnamestrings</span><span style="color: #000">=</span><span style="color: #00f">&quot;true&quot;</span>&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;overload-enabled&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;false&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;naming-scheme&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;mix&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #090">&lt;!--&nbsp;You&nbsp;may&nbsp;set&nbsp;this&nbsp;to&nbsp;'compatible'&nbsp;instead&nbsp;--&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;property&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;language-conformity&quot;</span>&nbsp;<span style="color: #606">value</span><span style="color: #000">=</span><span style="color: #00f">&quot;illegal&quot;</span>&nbsp;/&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;keep&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;class&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;${robot.classname}&quot;</span>&nbsp;<span style="color: #606">methods</span><span style="color: #000">=</span><span style="color: #00f">&quot;public&quot;</span>&nbsp;<span style="color: #606">fields</span><span style="color: #000">=</span><span style="color: #00f">&quot;none&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/keep&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/rename&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/yguard&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/target&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;target&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;deploy&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Deploy&nbsp;.jar&nbsp;file&nbsp;to&nbsp;robocode&nbsp;directory&nbsp;and&nbsp;make&nbsp;a&nbsp;backup&quot;</span>&nbsp;<span style="color: #606">depends</span><span style="color: #000">=</span><span style="color: #00f">&quot;buildjar&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;copy&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;${release.file}&quot;</span>&nbsp;<span style="color: #606">overwrite</span><span style="color: #000">=</span><span style="color: #00f">&quot;true&quot;</span>&nbsp;<span style="color: #606">todir</span><span style="color: #000">=</span><span style="color: #00f">&quot;${robocode.home}/robots&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;copy&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;${backup.file}&quot;</span>&nbsp;<span style="color: #606">overwrite</span><span style="color: #000">=</span><span style="color: #00f">&quot;true&quot;</span>&nbsp;<span style="color: #606">todir</span><span style="color: #000">=</span><span style="color: #00f">&quot;./backups&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/target&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;target&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;cleanup&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Cleanup&nbsp;.jar&nbsp;in&nbsp;target&nbsp;directory&quot;</span>&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;delete&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;${backup.file}&quot;</span>&nbsp;<span style="color: #606">failonerror</span><span style="color: #000">=</span><span style="color: #00f">&quot;false&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;delete&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;${release.file}&quot;</span>&nbsp;<span style="color: #606">failonerror</span><span style="color: #000">=</span><span style="color: #00f">&quot;false&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;delete&nbsp;<span style="color: #606">file</span><span style="color: #000">=</span><span style="color: #00f">&quot;${temp.file}&quot;</span>&nbsp;<span style="color: #606">failonerror</span><span style="color: #000">=</span><span style="color: #00f">&quot;false&quot;</span>&nbsp;/&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;/target&gt;</span><br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #c60">&lt;target&nbsp;<span style="color: #606">name</span><span style="color: #000">=</span><span style="color: #00f">&quot;build&quot;</span>&nbsp;<span style="color: #606">depends</span><span style="color: #000">=</span><span style="color: #00f">&quot;clean,deploy&quot;</span>&nbsp;<span style="color: #606">description</span><span style="color: #000">=</span><span style="color: #00f">&quot;Automatically&nbsp;build&nbsp;file&nbsp;and&nbsp;cleanup&quot;</span>&gt;&lt;/target&gt;</span><br /> <span style="color: #c60">&lt;/project&gt;</span></span>
<!-- ======================================================
 
 
 
                      ANT build file
 
                      Nat Pavasant
 
 
 
    ======================================================
 
 
Directory structure:
 
  - /bin - this will store all of classes files
 
  - /src - this will store all of source files
 
  - /resource - contain all the resources you want to include
 
                in .jar in the same structure
 
  - /backups - contain each and every build of your code.
 
 
 
Dependancies:
 
  - Pack task (http://sadun-util.sourceforge.net/pack.html)
 
  - yGuard Obfuscator (http://www.yworks.com/en/products_yguard_about.htm)
 
  - CodeSize version 1.0 (version 1.1 come with robocode now doesn't have valid entry point)
 
 
Configuration:
 
  - basedir - in <project> tag - must set to your working directory that
 
                                contains the structure
 
  - In task "init"
 
    - robot.name - robot classname
 
    - robot.package - robot package name
 
    - robot.propertiesfile - path to property file to created
 
    - ...
 
 
 
  Credit:
 
  - David Alves
 
  - Hexkid
 
 
 
======================================================= -->
 
<project name="Robot" default="build" basedir=".">
 
<description>
 
Build File
 
</description>
 
 
 
<!-- define a task use in this build file -->
 
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="./yguard.jar" />
 
<taskdef name="pack" classname="org.sadun.util.ant.Pack" classpath="./pack.jar" />
 
 
 
<!-- Initialize the config, all properties must be here -->
 
<target name="init" description="Initialize properties to build">
 
<tstamp>
 
<!-- configure time string use for backup version -->
 
<format property="timestamp" pattern="yyyyMMdHHmmss" locale="en,US" timezone="UTC" />
 
</tstamp>
 
 
 
<!-- Start configuration setting -->
 
<property name="robot.name" value="Your Robot Name" />
 
<property name="robot.package" value="Your Package Name" />
 
 
 
<!-- Set the path to your properties file inside .jar, please make sure
 
    that the specific directory is available under ./resource/ directory -->
 
<property name="robot.propertiesfile" value="Your package name/${robot.name}.properties" />
 
 
 
<!-- Create the property file that describes this robot -->
 
<propertyfile file="resource/${robot.propertiesfile}">
 
<entry key="robot.description" value="" />
 
<entry key="robot.java.source.included" value="false" />
 
<entry key="robocode.version" value="1.7.1.2" />
 
<entry key="robot.version" value="0.1" />
 
<entry key="robot.author.name" value="Your Name" />
 
<entry key="robot.classname" value="${robot.package}.${robot.name}" />
 
</propertyfile>
 
 
 
<property file="resource/${robot.propertiesfile}" description="Use the entries from the properties file within this script." />
 
<property name="robocode.home" value="C:\robocode" />
 
<property name="robocode.jar" location="${robocode.home}/libs/robocode.jar" />
 
<property name="codesize.jar" location="./codesize.jar" />
 
<property name="class.path" value="./bin;${robocode.jar}" />
 
 
 
<property name="COMPILECLASSNAME" value="" />
 
<property name="COMPILE_WITH_DEBUG" value="off" />
 
<property name="VERBOSE_LEVEL" value="1" />
 
 
 
<property name="backup.file" location="target/${robot.name}_${robot.version}_${timestamp}.jar" />
 
<property name="release.file" location="target/${robot.classname}_${robot.version}.jar" />
 
<property name="temp.file" location="target/${robot.name}_temp.jar" />
 
</target>
 
 
 
<!-- Clean up the build -->
 
<target name="clean" depends="init" description="Remove the directories containing the classes and the jar file">
 
<delete dir="bin" />
 
<delete dir="target" />
 
</target>
 
 
 
<target name="prepare" depends="init" description="Create the generated directories">
 
<mkdir dir="bin" />
 
<mkdir dir="target" />
 
</target>
 
 
 
<target name="compile" depends="prepare" description="Compile the Java classes">
 
<javac srcdir="src" destdir="bin" classpath="${class.path}" debug="${COMPILE_WITH_DEBUG}" includes="**/*.java" />
 
</target>
 
 
 
<target name="buildjar" depends="compile" description="make .jar file">
 
<delete file="${backup.file}" failonerror="false" />
 
<delete file="${release.file}" failonerror="false" />
 
<delete file="${temp.file}" failonerror="false" />
 
 
 
<jar duplicate="add" destfile="${backup.file}" compress="true">
 
<fileset dir="bin" includes="**/*.class" />
 
<fileset dir="src" includes="**/*.java" />
 
<fileset dir="resource" includes="**/*" />
 
</jar>
 
 
 
<pack classes="${robot.classname}" targetjar="${temp.file}" excludepkg="java,javax,sun,robocode">
 
<classpath path="./bin" />
 
<classpath location="${robocode.jar}" />
 
<additionalfileset dir="resource" includes="**/*" />
 
</pack>
 
 
 
<!-- Print codesize-->
 
<java fork="yes" jar="${codesize.jar}">
 
<arg value="${temp.file}" />
 
</java>
 
 
 
<!-- Obfuscate release jar -->
 
<yguard>
 
<inoutpair in="${temp.file}" out="${release.file}" />
 
 
 
<externalclasses>
 
<pathelement location="${robocode.jar}" />
 
</externalclasses>
 
 
 
<rename logfile="obfuscate.log" replaceclassnamestrings="true">
 
 
 
<property name="overload-enabled" value="false" />
 
<property name="naming-scheme" value="mix" />
 
<!-- You may set this to 'compatible' instead -->
 
<property name="language-conformity" value="illegal" />
 
 
 
<keep>
 
<class name="${robot.classname}" methods="public" fields="none" />
 
</keep>
 
</rename>
 
</yguard>
 
</target>
 
 
 
<target name="deploy" description="Deploy .jar file to robocode directory and make a backup" depends="buildjar">
 
<copy file="${release.file}" overwrite="true" todir="${robocode.home}/robots" />
 
<copy file="${backup.file}" overwrite="true" todir="./backups" />
 
</target>
 
 
 
<target name="cleanup" description="Cleanup .jar in target directory">
 
<delete file="${backup.file}" failonerror="false" />
 
<delete file="${release.file}" failonerror="false" />
 
<delete file="${temp.file}" failonerror="false" />
 
</target>
 
 
 
<target name="build" depends="clean,deploy" description="Automatically build file and cleanup"></target>
 
</project>
 
</pre>
 

Latest revision as of 05:30, 17 May 2009

Just start using ant recently. I now come up with my own ant build file base on two example files on the old wiki. Have fun!

Documentation

Directory structure
  • /bin - this will store all of classes files
  • /src - this will store all of source files
  • /resource - contain all the resources you want to include in .jar in the same structure
  • /backups - contain each and every build of your code.
Dependancies
Configuration
  • basedir - in <project> tag - must set to your working directory thatcontains the structure
  • In task "init"
    • robot.name - robot classname
    • robot.package - robot package name
    • robot.propertiesfile - path to property file to created
    • ...
Credit

Features

  • Automatically packed only required file
  • Deploy to robots folder automatically
  • Automatically backup every builds.
  • Obfuscate the JAR file so no one can take your code by decompiler.
  • Very easy configuration (I think)
  • Automatically pack resources if any.

Note that this build file create the closed-source robot, if you are open sources, you may have to edit it a bit to use the backup files instead (the backup file will include everything in your project). But for someone want to publish their source code but want to obfuscate the jar file too like me, you can use this build file and publish the source code through other context.

XML File

Because color make you memorization better by 72%, so... (but I can't disabled the auto line break TT) <?xml version="1.0" encoding="utf-8" ?>
<!-- ======================================================

                      ANT build file
                       Nat Pavasant

     ======================================================
 
 Directory structure:
  - /bin - this will store all of classes files
  - /src - this will store all of source files
  - /resource - contain all the resources you want to include 
                in .jar in the same structure
  - /backups - contain each and every build of your code.
  
 Dependancies:
  - Pack task (http://sadun-util.sourceforge.net/pack.html)
  - yGuard Obfuscator (http://www.yworks.com/en/products_yguard_about.htm)
  - CodeSize version 1.0 (version 1.1 come with robocode now doesn't have valid entry point)
 
 Configuration:
  - basedir - in <project> tag - must set to your working directory that
                                 contains the structure
  - In task 'init'
    - robot.name - robot classname
    - robot.package - robot package name
    - robot.propertiesfile - path to property file to created
    - ...
  
  Credit:
   - David Alves
   - Hexkid

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

<project name="Robot" default="build" basedir=".">
    <description>
        Build File
    </description>

    <!-- define a task use in this build file -->
    <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="./yguard.jar" />
    <taskdef name="pack" classname="org.sadun.util.ant.Pack" classpath="./pack.jar" />

    <!-- Initialize the config, all properties must be here -->
    <target name="init" description="Initialize properties to build">
        <tstamp>
            <!-- configure time string use for backup version -->
            <format property="timestamp" pattern="yyyyMMdHHmmss" locale="en,US" timezone="UTC" />
        </tstamp>

        <!-- Start configuration setting -->
        <property name="robot.name" value="Your Robot Name" />
        <property name="robot.package" value="Your Package Name" />

        <!-- Set the path to your properties file inside .jar, please make sure 
             that the specific directory is available under ./resource/ directory -->

        <property name="robot.propertiesfile" value="Your package name/${robot.name}.properties" />

        <!-- Create the property file that describes this robot -->
        <propertyfile file="resource/${robot.propertiesfile}">
            <entry key="robot.description" value="" />
            <entry key="robot.java.source.included" value="false" />
            <entry key="robocode.version" value="1.7.1.2" />
            <entry key="robot.version" value="0.1" />
            <entry key="robot.author.name" value="Your Name" />
            <entry key="robot.classname" value="${robot.package}.${robot.name}" />
        </propertyfile>

        <property file="resource/${robot.propertiesfile}" description="Use the entries from the properties file within this script." />
        <property name="robocode.home" value="C:\robocode" />
        <property name="robocode.jar" location="${robocode.home}/libs/robocode.jar" />
        <property name="codesize.jar" location="./codesize.jar" />
        <property name="class.path" value="./bin;${robocode.jar}" />

        <property name="COMPILECLASSNAME" value="" />
        <property name="COMPILE_WITH_DEBUG" value="off" />
        <property name="VERBOSE_LEVEL" value="1" />

        <property name="backup.file" location="target/${robot.name}_${robot.version}_${timestamp}.jar" />
        <property name="release.file" location="target/${robot.classname}_${robot.version}.jar" />
        <property name="temp.file" location="target/${robot.name}_temp.jar" />
    </target>

    <!-- Clean up the build -->
    <target name="clean" depends="init" description="Remove the directories containing the classes and the jar file">
        <delete dir="bin" />
        <delete dir="target" />
    </target>

    <target name="prepare" depends="init" description="Create the generated directories">
        <mkdir dir="bin" />
        <mkdir dir="target" />
    </target>

    <target name="compile" depends="prepare" description="Compile the Java classes">
        <javac srcdir="src" destdir="bin" classpath="${class.path}" debug="${COMPILE_WITH_DEBUG}" includes="**/*.java" />
    </target>

    <target name="buildjar" depends="compile" description="Make .jar file">
        <delete file="${backup.file}" failonerror="false" />
        <delete file="${release.file}" failonerror="false" />
        <delete file="${temp.file}" failonerror="false" />

        <jar duplicate="add" destfile="${backup.file}" compress="true">
            <fileset dir="bin" includes="**/*.class" />
            <fileset dir="src" includes="**/*.java" />
            <fileset dir="resource" includes="**/*" />
        </jar>

        <pack classes="${robot.classname}" targetjar="${temp.file}" excludepkg="java,javax,sun,robocode">
            <classpath path="./bin" />
            <classpath location="${robocode.jar}" />
            <additionalfileset dir="resource" includes="**/*" />
        </pack>

        <!-- Print codesize-->
        <java fork="yes" jar="${codesize.jar}">
            <arg value="${temp.file}" />
        </java>

        <!-- Obfuscate release jar -->
        <yguard>
            <inoutpair in="${temp.file}" out="${release.file}" />

            <externalclasses>
                <pathelement location="${robocode.jar}" />
            </externalclasses>

            <rename logfile="obfuscate.log" replaceclassnamestrings="true">

                <property name="overload-enabled" value="false" />
                <property name="naming-scheme" value="mix" />
                <!-- You may set this to 'compatible' instead -->
                <property name="language-conformity" value="illegal" />

                <keep>
                    <class name="${robot.classname}" methods="public" fields="none" />
                </keep>
            </rename>
        </yguard>
    </target>

    <target name="deploy" description="Deploy .jar file to robocode directory and make a backup" depends="buildjar">
        <copy file="${release.file}" overwrite="true" todir="${robocode.home}/robots" />
        <copy file="${backup.file}" overwrite="true" todir="./backups" />
    </target>

    <target name="cleanup" description="Cleanup .jar in target directory">
        <delete file="${backup.file}" failonerror="false" />
        <delete file="${release.file}" failonerror="false" />
        <delete file="${temp.file}" failonerror="false" />
    </target>

    <target name="build" depends="clean,deploy" description="Automatically build file and cleanup"></target>
</project>