Tutorials/howto ant

From CubeiaWiki

Revision as of 12:43, 2 October 2012 by Larsan (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Firebase and Ant

Firebase comes with extensive support for building games, services and tournaments with Apache Maven. However, convenient as this is, it is not a requirement. This page describes a build in Apache Ant, but should be useful as a references for any Maven deprived build.

Requirements and Setup

You need a basic understanding of Firebase as well as Apache Ant installed.

The build file used in all examples assumes the following structure:

"/bin" - for compiled classes
"/tmp" - temporary work directory
"/src" - java sources
"/xml" - xml descriptors 
"/lib" - dependencies

Dependencies are assumed to be JAR files in the "lib/" folder, but in reality a more robust dendency mechanism should be used. The following properties will be assumed:

<property name="version" value="1.0-SNAPSHOT" />
<property name="firebase-version" value="1.9.0-CE" />


Compile as you would normally. For any Firebase archetype you will need the API JAR in the class path. If you don't have it locally you can download it from Cubeia's Maven repository.

<target name="get-firebase-api">
    <get src="http://m2.cubeia.com/nexus/content/groups/public/com/cubeia/firebase/firebase-api/${firebase-version}/firebase-api-${firebase-version}.jar" dest="tmp/" />

The above JAR can then be included in the compilation class path. For example:

<!-- Setup classpath -->
<path id="compile-cp">
    <!-- All JAR files in "lib/" -->
    <fileset dir="lib/">
        <include name="*.jar"/>
    <!-- Include Firebase API JAR -->
    <fileset dir="tmp/">
        <include name="firebase-api-${firebase-version}.jar" />
<!-- Compile -->
<target name="compile" depends="init,get-firebase-api" description="compile the source" >
    <javac srcdir="src/" destdir="bin/" includeantruntime="false">
        <classpath refid="compile-cp"/>


Game Archive

The packaging of a GAR file would look like this:

<target name="package" depends="compile" description="package GAR file" >
    <jar jarfile="tmp/game-${version}.jar" basedir="bin/"/>
    <zip destfile="game-${version}.gar">
        <fileset file="tmp/game-${version}.jar" />
        <!-- Add game.xml and all dependencies -->
        <zipfileset file="xml/game.xml" prefix="GAME-INF" />
        <zipfileset dir="lib/" prefix="GAME-INF/lib" />


  • Example Game project.
Personal tools