2 template Ant build file for all projects that should go into the distribution.
\r
3 Fill out the properties at the beginning of the project definition.
\r
5 The following things have to be set from the outside:
\r
7 property name="jar" value="jar-name-without-suffix" -> the name of the resulting jar file
\r
8 property name="distDir" value="dist-directory" -> the output directory for the resulting jar
\r
9 path id="classpath" -> the filesets defining the classpath needed to compile the project
\r
10 zipfileset id="jarfiles" -> the jar files to be merged with the project's classes
\r
12 <project name="template" default="all" basedir=".">
\r
13 <!-- default values -->
\r
14 <property name="src" value="src"/>
\r
15 <property name="jni" value="jni"/>
\r
16 <property name="target" value="target" />
\r
17 <property name="libs" value="libs" />
\r
18 <path id="classpath"/>
\r
19 <zipfileset id="jarfiles" dir="." excludes="**"/>
\r
21 <!-- clean output directories -->
\r
22 <target name="clean">
\r
23 <delete dir="${target}" />
\r
26 <!-- init task, creates all necessary directories -->
\r
27 <target name="init" depends="clean">
\r
28 <mkdir dir="${libs]" />
\r
29 <mkdir dir="${target}" />
\r
30 <mkdir dir="${target}/java" />
\r
31 <!-- need to copy the internal font to target if compiling the gdx core :/ -->
\r
32 <copy failonerror="false" tofile="${target}/java/com/badlogic/gdx/utils/arial-15.png" file="src/com/badlogic/gdx/utils/arial-15.png" />
\r
33 <copy failonerror="false" tofile="${target}/java/com/badlogic/gdx/utils/arial-15.fnt" file="src/com/badlogic/gdx/utils/arial-15.fnt" />
\r
34 <!-- need to copy jni headers for gdx-jnigen -->
\r
35 <copy failonerror="false" todir="${target}/java">
\r
37 <include name="**/*.h"/>
\r
38 <include name="**/*.template"/>
\r
41 <copy failonerror="false" todir="${target}/java">
\r
43 <include name="**/*.gwt.xml"/>
\r
48 <!-- compiles the java code -->
\r
49 <target name="compile" depends="init">
\r
50 <javac debug="on" encoding="utf-8" srcdir="${src}" destdir="${target}/java">
\r
52 <path refid="classpath"/>
\r
53 <fileset file="${libs}/*.jar">
\r
54 <exclude name="*-natives.jar"/>
\r
57 <exclude name="**/gwt/emu/java/lang/System.java"/>
\r
62 <!-- compile native code if available -->
\r
63 <target name="check-natives">
\r
64 <condition property="natives-present">
\r
66 <available file="${jni}/build.xml"/>
\r
67 <istrue value="${build-natives}"/>
\r
71 <target name="compile-natives" depends="init, check-natives" if="natives-present">
\r
72 <echo message="compiling natives code"/>
\r
73 <ant antfile="build.xml" target="clean" dir="${jni}"/>
\r
74 <ant antfile="build.xml" target="all" dir="${jni}"/>
\r
75 <!-- copy shared libs for android -->
\r
76 <copy failonerror="false" todir="${distDir}/armeabi">
\r
77 <fileset dir="${libs}/armeabi">
\r
78 <include name="**/*.so"/>
\r
81 <copy failonerror="false" todir="${distDir}/armeabi-v7a">
\r
82 <fileset dir="${libs}/armeabi-v7a">
\r
83 <include name="**/*.so"/>
\r
88 <!-- create source and class jar -->
\r
89 <target name="all" depends="compile,compile-natives">
\r
91 <mkdir dir="${distDir}/sources" />
\r
92 <jar destfile="${distDir}/sources/${jar}-sources.jar" basedir="${src}" />
\r
94 <!-- copy shared libs for desktop -->
\r
95 <copy failonerror="false" todir="${distDir}">
\r
96 <fileset dir="${libs}">
\r
97 <include name="**/*-natives.jar"/>
\r
98 <exclude name="**/test-natives.jar"/>
\r
102 <!-- copy shared libs for android -->
\r
103 <copy failonerror="false" todir="${distDir}/armeabi">
\r
104 <fileset dir="${libs}/armeabi">
\r
105 <include name="**/*.so"/>
\r
108 <copy failonerror="false" todir="${distDir}/armeabi-v7a">
\r
109 <fileset dir="${libs}/armeabi-v7a">
\r
110 <include name="**/*.so"/>
\r
115 <jar destfile="${distDir}/${jar}.jar">
\r
116 <fileset dir="${target}/java"/>
\r
117 <!-- merge dependencies found in libs/ folder, exclude native, debug and android/gwt jars -->
\r
118 <zipgroupfileset file="${libs}/*.jar">
\r
119 <exclude name="*-natives.jar"/>
\r
120 <exclude name="*-debug.jar"/>
\r
121 <exclude name="android-*.jar"/>
\r
122 <exclude name="gwt*.jar"/>
\r
124 <!-- merge dependencies specified in parent build.xml -->
\r
125 <zipfileset refid="jarfiles"/>
\r