1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!-- Apache Ant build script for building the Robocode setup file -->
<!-- ====================================================================== -->
<project name="build" default="archive">
<description>Apache Ant build script for building the Robocode archive files</description>
<!-- ====================================== -->
<!-- Global properties -->
<!-- ====================================== -->
<!-- Read out the version from the versions.txt -->
<loadfile property="version" srcfile="../robocode/resources/versions.txt">
<filterchain>
<headfilter lines="1"/>
<replacestring from="Version " to=""/>
<replacestring from=" " to="-"/>
<striplinebreaks/>
</filterchain>
</loadfile>
<!-- Disable debug information when compiling -->
<property name="debug" value="off"/> <!-- Debug information is stripped from the setup file -->
<!-- The build folder -->
<property name="build" location="build"/>
<!-- The source folders -->
<property name="src.robocode" location="../robocode"/>
<property name="src.extract" location="../robocodeextract"/>
<property name="src.autoextract" location="../autoextract"/>
<property name="src.robots" location="../robocodeextract/robots"/>
<property name="src.roborumble" location="../roborumble"/>
<property name="src.cachecleaner" location="../robocode/ar"/>
<property name="src.tests" location="../tests"/>
<property name="src.testrobots" location="../tests/robots"/>
<!-- License file -->
<property name="license.file" location="${src.extract}/license/cpl-v10.html"/>
<!-- Versions file -->
<property name="versions.file" location="${src.robocode}/resources/versions.txt"/>
<!-- The output archive files -->
<property name="setup.archive" value="robocode-setup-${version}.jar"/>
<property name="sources.archive" value="robocode-src-${version}.zip"/>
<!-- ====================================== -->
<!-- Default Excludes -->
<!-- ====================================== -->
<defaultexcludes add="build.xml"/> <!-- Ant build scripts -->
<defaultexcludes add="**/.*/**"/> <!-- Eclipse configuration folders -->
<defaultexcludes add="**/*.iml"/> <!-- IDEA -->
<defaultexcludes add="**/*.ipr"/> <!-- IDEA -->
<defaultexcludes add="**/*.iws"/> <!-- IDEA -->
<defaultexcludes add="**/*.bak"/> <!-- Windows backup files -->
<defaultexcludes add="**/Thumbs.db"/> <!-- Windows thumbs databases -->
<defaultexcludes add="**/~*"/> <!-- Unix backup files -->
<defaultexcludes add="**/.*"/> <!-- Hidden unix file types -->
<defaultexcludes add="**/.svn/**"/> <!-- Subversion directories -->
<defaultexcludes add="**/_svn/**"/> <!-- Subversion directories -->
<defaultexcludes add="**/launch/**"/> <!-- Robocode launch directory -->
<!-- ====================================== -->
<!-- Target: init -->
<!-- ====================================== -->
<target
name="init"
description="Initializes the build">
<echo message="Initializes the build..."/>
<!-- Create timestamp -->
<tstamp/>
<!-- Create folder for containing build files -->
<mkdir dir="${build}/libs"/>
</target>
<!-- ====================================== -->
<!-- Target: archive -->
<!-- ====================================== -->
<target
name="archive"
description="Build the Robocode distribution files"
depends="archive.setup, archive.sources"
/>
<!-- ====================================== -->
<!-- Target: archive.setup -->
<!-- ====================================== -->
<target
name="archive.setup"
description="Build the Robocode setup archive"
depends="clean, extract.jar, compile.autoextract">
<echo message="Building Robocode setup archive (${setup.archive})..."/>
<!-- Create the Robocode setup archive -->
<jar destfile="${build}/${setup.archive}">
<!-- Specify files to include -->
<fileset dir="${build}" includes="robocode/AutoExtract.class"/> <!-- Auto extract class -->
<fileset file="${build}/extract.jar"/> <!-- extract.jar file -->
<!-- Set the main class of the manifest -->
<manifest>
<attribute name="Implementation-Title" value="Robocode installer"/>
<attribute name="Implementation-Version" value="v${version}, ${TODAY}"/>
<attribute name="Implementation-Vendor" value="Mathew A. Nelson, Flemming N. Larsen"/>
<attribute name="Main-Class" value="robocode.AutoExtract"/>
</manifest>
</jar>
</target>
<!-- ====================================== -->
<!-- Target: archive.sources -->
<!-- ====================================== -->
<target
name="archive.sources"
description="Zip all source files">
<echo message="Building Robocode sources archive (${sources.archive})..."/>
<zip
destfile="${build}/${sources.archive}"
basedir=".."
includes="autoextract/**, build/*, robocode/**, robocodeextract/**, roborumble/**, tools/**"
excludes="build/build, **/bin/**, **/.svn/**, **/_svn/**, **/launch/**"
defaultexcludes="no"
/>
</target>
<!-- ====================================== -->
<!-- Target: compile.robocode -->
<!-- ====================================== -->
<target
name="compile.robocode"
description="Compile Robocode"
depends="init"
unless="robocode.uptodate">
<echo message="Compiling Robocode..."/>
<!-- Compile Robocode -->
<compile srcdir="${src.robocode}" destdir="${build}" classpath="bcel.jar"/>
<!-- Flag that Robocode has been built -->
<touch file="${build}/.robocode_build"/>
</target>
<uptodate property="robocode.uptodate" targetfile="${build}/.robocode_build">
<srcfiles dir="${src.robocode}/robocode"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: compile.robots -->
<!-- ====================================== -->
<target
name="compile.robots"
description="Compile robots"
depends="init, compile.robocode"
unless="robots.uptodate">
<echo message="Compiling robots..."/>
<!-- Compile robots -->
<compile srcdir="${src.extract}/robots" destdir="${build}/robots" classpath="${build}"/>
<!-- Flag that robots have been built -->
<touch file="${build}/.robots_build"/>
</target>
<uptodate property="robots.uptodate" targetfile="${build}/.robots_build">
<srcfiles dir="${src.robots}"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: compile.testrobots -->
<!-- ====================================== -->
<target
name="compile.testrobots"
description="Compile testing robots"
depends="init, compile.robocode"
unless="testrobots.uptodate">
<echo message="Compiling testrobots..."/>
<!-- Compile robots -->
<compile srcdir="${src.testrobots}" destdir="${build}/robots" classpath="${build}"/>
<copy file="${src.testrobots}/testing/TestTeam.team" toDir="${build}/robots/testing"/>
<!-- Flag that robots have been built -->
<touch file="${build}/.testrobots_build"/>
</target>
<uptodate property="testrobots.uptodate" targetfile="${build}/.testrobots_build">
<srcfiles dir="${src.testrobots}"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: compile.tests -->
<!-- ====================================== -->
<target
name="compile.tests"
description="Compile tests"
depends="init, robocode.jar"
unless="tests.uptodate">
<echo message="Compiling tests..."/>
<!-- Compile Robocode -->
<compile srcdir="${src.tests}/tests" destdir="${build}/tests" classpath="bcel.jar;${build}/libs/robocode.jar;${src.tests}/libs/junit-4.4.jar"/>
<!-- Flag that Robocode has been built -->
<touch file="${build}/.tests_build"/>
</target>
<uptodate property="tests.uptodate" targetfile="${build}/.tests_build">
<srcfiles dir="${src.tests}/tests"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: compile.autoextract -->
<!-- ====================================== -->
<target
name="compile.autoextract"
description="Compile AutoExtract"
depends="init"
unless="autoextract.uptodate">
<echo message="Compiling AutoExtract..."/>
<!-- Compile AutoExtract -->
<compile srcdir="${src.autoextract}" destdir="${build}"/>
</target>
<uptodate property="autoextract.uptodate" targetfile="${build}/robocode/AutoExtract.class">
<srcfiles dir="${src.autoextract}"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: compile.roborumble -->
<!-- ====================================== -->
<target
name="compile.roborumble"
description="Compile RoboRumble"
depends="init"
unless="roborumble.uptodate">
<echo message="Compiling RoboRumble..."/>
<!-- Compile RoboRumble -->
<compile srcdir="${src.roborumble}" destdir="${build}" classpath="bcel.jar"/>
<!-- Flag that RoboRumble has been built -->
<touch file="${build}/.roborumble_build"/>
</target>
<uptodate property="roborumble.uptodate" targetfile="${build}/.roborumble_build">
<srcfiles dir="${src.roborumble}/roborumble"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: compile.cachecleaner -->
<!-- ====================================== -->
<target
name="compile.cachecleaner"
description="Compile CacheCleaner"
depends="init"
unless="cachecleaner.uptodate">
<echo message="Compiling CacheCleaner..."/>
<!-- Compile CacheCleaner -->
<compile srcdir="${src.cachecleaner}" destdir="${build}"/>
<!-- Flag that CacheCleaner has been built -->
<touch file="${build}/.cachecleaner_build"/>
</target>
<uptodate property="cachecleaner.uptodate" targetfile="${build}/.cachecleaner_build">
<srcfiles dir="${src.cachecleaner}"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: robocode.jar -->
<!-- ====================================== -->
<target
name="robocode.jar"
description="Build robocode.jar"
depends="init, compile.robocode"
unless="robocode.jar.uptodate">
<echo message="Building robocode.jar..."/>
<!-- Create the robocode.jar file -->
<jar destfile="${build}/libs/robocode.jar">
<!-- Specify files to include -->
<fileset dir="${build}" includes="robocode/**"> <!-- Class files -->
<exclude name="robocode/AutoExtract.class"/> <!-- Exclude AutoExtract.class -->
</fileset>
<fileset dir="${src.robocode}" includes="resources/**"/> <!-- Resource files -->
<fileset file="${license.file}"/> <!-- License file -->
<!-- Set the main class of the manifest -->
<manifest>
<attribute name="Implementation-Title" value="Robocode"/>
<attribute name="Implementation-Version" value="v${version}, ${TODAY}"/>
<attribute name="Implementation-Vendor" value="Mathew A. Nelson, Flemming N. Larsen, and other Robocode contributors"/>
<attribute name="Main-Class" value="robocode.Robocode"/>
</manifest>
</jar>
</target>
<uptodate property="robocode.jar.uptodate" targetfile="${build}/libs/robocode.jar">
<srcfiles dir="${src.robocode}"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: extract.jar -->
<!-- ====================================== -->
<target
name="extract.jar"
description="Build extract.jar"
depends="init, robocode.jar, roborumble.jar, compile.robots, cachecleaner.jar, javadoc"
unless="extract.jar.uptodate">
<echo message="Building extract.jar..."/>
<!-- Create the extract.jar file -->
<jar destfile="${build}/extract.jar">
<!-- Specify files to include -->
<fileset dir="${src.extract}"> <!-- Files from the extract folder -->
<exclude name="build/**"/> <!-- Exclude build files (if any) -->
<exclude name="bin/**"/> <!-- Binary files (Eclipse build) -->
<exclude name="**/.svn/**"/> <!-- Exclude subversion files (if any) -->
<exclude name="**/_svn/**"/> <!-- Exclude subversion files (if any) -->
</fileset>
<fileset dir="${src.roborumble}"> <!-- Files from the roborumble folder -->
<include name="*.bat"/> <!-- Windows batch files -->
<include name="*.sh"/> <!-- Shell files (Mac, Linux, and similar) -->
<include name="config/*"/> <!-- Configuration files -->
<exclude name="bin/**"/> <!-- Binary files (Eclipse build) -->
<exclude name="**/.svn/**"/> <!-- Exclude subversion files (if any) -->
<exclude name="**/_svn/**"/> <!-- Exclude subversion files (if any) -->
</fileset>
<fileset dir="${build}">
<include name="libs/robocode.jar"/> <!-- Builded robocode.jar -->
<include name="libs/roborumble.jar"/> <!-- Builded roborumble.jar -->
<include name="libs/cachecleaner.jar"/> <!-- Builded cachecleaner.jar -->
<include name="javadoc/**"/> <!-- Builded javadoc files -->
<include name="robots/**"/> <!-- Builded robots -->
</fileset>
<fileset file="${versions.file}"/> <!-- Versions file -->
</jar>
</target>
<uptodate property="extract.jar.uptodate" targetfile="${build}/extract.jar">
<srcfiles dir="${src.extract}" excludes="build/**"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: roborumble.jar -->
<!-- ====================================== -->
<target
name="roborumble.jar"
description="Build roborumble.jar"
depends="init, compile.robocode, compile.roborumble"
unless="roborumble.jar.uptodate">
<echo message="Building roborumble.jar..."/>
<!-- Create the roborumble.jar file -->
<jar destfile="${build}/libs/roborumble.jar">
<!-- Specify files to include -->
<fileset dir="${build}" includes="roborumble/**"/> <!-- Class files -->
<fileset file="${license.file}"/> <!-- License file -->
<!-- Set the main class of the manifest -->
<manifest>
<attribute name="Implementation-Title" value="RoboRumble@Home"/>
<attribute name="Implementation-Version" value="v${version}, ${TODAY}"/>
<attribute name="Implementation-Vendor" value="Albert Pérez, Flemming N. Larsen, and other Robocode contributors"/>
<attribute name="Main-Class" value="roborumble.RoboRumbleAtHome"/>
</manifest>
</jar>
</target>
<uptodate property="roborumble.jar.uptodate" targetfile="${build}/libs/roborumble.jar">
<srcfiles dir="${src.roborumble}"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: cachecleaner.jar -->
<!-- ====================================== -->
<target
name="cachecleaner.jar"
description="Build cachecleaner.jar"
depends="init, compile.cachecleaner"
unless="cachecleaner.jar.uptodate">
<echo message="Building cachecleaner.jar..."/>
<!-- Create the cachecleaner.jar file -->
<jar destfile="${build}/libs/cachecleaner.jar">
<!-- Specify files to include -->
<fileset dir="${build}" includes="ar/**"/> <!-- Class files -->
<!-- Set the main class of the manifest -->
<manifest>
<attribute name="Implementation-Title" value="CacheCleaner for Robocode"/>
<attribute name="Implementation-Version" value="v${version}, ${TODAY}"/>
<attribute name="Implementation-Vendor" value="AaronR"/>
<attribute name="Main-Class" value="ar.robocode.cachecleaner.CacheCleaner"/>
</manifest>
</jar>
</target>
<uptodate property="cachecleaner.jar.uptodate" targetfile="${build}/libs/cachecleaner.jar">
<srcfiles dir="${src.cachecleaner}"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: run junit tests -->
<!-- ====================================== -->
<target
name="run.tests"
description="Run tests"
depends="init, compile.tests, compile.testrobots, compile.robots"
unless="tests.green">
<echo message="Running tests..."/>
<junit printsummary="yes" haltonfailure="yes" dir="${build}">
<classpath>
<pathelement location="${build}/tests"/>
<pathelement location="${build}/libs/robocode.jar"/>
<pathelement location="bcel.jar"/>
<pathelement location="${src.tests}/libs/junit-4.4.jar"/>
</classpath>
<formatter type="plain"/>
<batchtest fork="yes" todir="${build}/tests">
<fileset dir="${src.tests}/tests">
<include name="**/*Test*.java"/>
<exclude name="**/RobotTestBed.java"/>
</fileset>
</batchtest>
</junit>
<!-- Flag that Robocode has been built -->
<touch file="${build}/.tests_run"/>
</target>
<uptodate property="tests.green" targetfile="${build}/.tests_green">
<srcfiles dir="${src.tests}/tests"/>
<srcfiles dir="${src.robocode}/robocode"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: javadoc -->
<!-- ====================================== -->
<target
name="javadoc"
description="Generate javadoc"
depends="init"
unless="javadoc.uptodate">
<echo message="Generating javadoc..."/>
<!-- Generate the javadoc documentation -->
<javadoc
destdir="${build}/javadoc"
sourcepath="${src.robocode}"
excludepackagenames="robocode.*, codesize.*, ar.*"
windowtitle="Robocode ${version} API"
link="/usr/share/doc/default-jdk-doc/api/">
<fileset dir="${src.robocode}" defaultexcludes="yes">
<include name="robocode/*.java"/>
<exclude name="robocode/_*.java"/>
<include name="robocode/util/Utils.java"/>
<include name="robocode/control/**/*.java"/>
<exclude name="robocode/control/RandomFactory.java"/>
<include name="robocode/robotinterfaces/**/*.java"/>
</fileset>
<doctitle><![CDATA[<h1>Robocode ${version} API</h1>]]></doctitle>
</javadoc>
<!-- Flag that javadoc has been built -->
<touch file="${build}/.javadoc_build"/>
</target>
<uptodate property="javadoc.uptodate" targetfile="${build}/.javadoc_build">
<srcfiles dir="${src.robocode}" includes="**/*.java"/>
</uptodate>
<!-- ====================================== -->
<!-- Target: install -->
<!-- ====================================== -->
<target
name="install"
description="Install Robocode"
depends="archive.setup">
<echo message="Installing Robocode..."/>
<!-- Run the Robocode setup file -->
<java jar="${setup.file}" fork="true"/>
</target>
<!-- ====================================== -->
<!-- Target: quick-install -->
<!-- ====================================== -->
<target
name="quick-install"
description="Quick install Robocode"
depends="extract.jar">
<echo message="Quick-installing Robocode..."/>
<!-- Ask user where to install Robocode -->
<input
message="To which folder do you want to install Robocode?"
addproperty="install.dir"/>
<!-- Create the installation folder -->
<mkdir dir="${install.dir}"/>
<!-- Extract the extract.jar into the installation folder -->
<unjar src="${build}/extract.jar" dest="${install.dir}"/>
</target>
<!-- ====================================== -->
<!-- Target: clean -->
<!-- ====================================== -->
<!-- Clean up all build files -->
<target
name="clean"
description="Clean up build files">
<echo message="Cleaning up build files..."/>
<!-- Delete the folder containing all build files -->
<delete dir="${build}"/>
</target>
<!-- ====================================== -->
<!-- Macro: compile -->
<!-- ====================================== -->
<macrodef name="compile">
<attribute name="srcdir"/>
<attribute name="destdir"/>
<attribute name="classpath" default=""/>
<sequential>
<!-- Create folder for class files -->
<mkdir dir="@{destdir}"/>
<!-- Compile the sources -->
<javac
encoding="8859_1"
srcdir="@{srcdir}"
destdir="@{destdir}"
classpath="@{classpath}"
source="1.5"
target="1.5"
debug="${debug}"
debuglevel="lines,vars,source"
optimize="true"
includes="**/*.java">
<compilerarg value="-Xlint"/>
</javac>
</sequential>
</macrodef>
</project>
|