<!--
template Ant build file for all projects that should go into the distribution.
Fill out the properties at the beginning of the project definition.
The following things have to be set from the outside:
property name="jar" value="jar-name-without-suffix" -> the name of the resulting jar file
property name="distDir" value="dist-directory" -> the output directory for the resulting jar
path id="classpath" -> the filesets defining the classpath needed to compile the project
zipfileset id="jarfiles" -> the jar files to be merged with the project's classes
-->
<project name="template" default="all" basedir=".">
<!-- default values -->
<path id="src">
<pathelement location="src"/>
</path>
<path id="classpath"/>
<property name="jni" value="jni"/>
<property name="target" value="target" />
<property name="libs" value="libs" />
<zipfileset id="jarfiles" dir="." excludes="**"/>
<fileset id="resourcefiles" dir="." excludes="**"/>
<!-- clean output directories, create libs directory -->
<target name="clean">
<mkdir dir="${libs}" />
<delete dir="${target}" />
</target>
<!-- init task, creates all necessary directories -->
<target name="init" depends="clean">
<mkdir dir="${target}" />
<mkdir dir="${target}/java" />
<!-- need to copy jni headers for gdx-jnigen -->
<copy failonerror="false" todir="${target}/java">
<fileset dir="src">
<include name="**/*.h"/>
<include name="**/*.template"/>
</fileset>
</copy>
<copy failonerror="false" todir="${target}/java">
<fileset dir="src">
<include name="**/*.gwt.xml"/>
</fileset>
</copy>
</target>
<!-- compiles the java code -->
<target name="compile" depends="init">
<javac debug="on" encoding="utf-8" source="1.6" target="1.6" destdir="${target}/java" includeantruntime="false">
<src>
<path refid="src"/>
</src>
<classpath>
<path refid="classpath"/>
<fileset file="${libs}/*.jar">
<exclude name="*-natives.jar"/>
</fileset>
</classpath>
<exclude name="**/gwt/emu/java/lang/System.java"/>
</javac>
</target>
<!-- compile native code if available -->
<target name="check-natives">
<condition property="natives-present">
<and>
<available file="${jni}/build.xml"/>
<istrue value="${build-natives}"/>
</and>
</condition>
</target>
<target name="compile-natives" depends="init, check-natives" if="natives-present">
<mkdir dir="${libs}/android32" />
<mkdir dir="{libs}/arm64-v8a" />
<mkdir dir="${libs}/armeabi" />
<mkdir dir="${libs}/armeabi-v7a" />
<mkdir dir="${libs}/x86" />
<mkdir dir="${libs}/x86_64" />
<mkdir dir="${libs}/linux32" />
<mkdir dir="${libs}/linux64" />
<mkdir dir="${libs}/macosx32" />
<mkdir dir="${libs}/macosx64" />
<mkdir dir="${libs}/windows32" />
<mkdir dir="${libs}/windows64" />
<mkdir dir="${libs}/ios32"/>
<echo message="compiling natives code"/>
<ant antfile="build.xml" target="clean" dir="${jni}"/>
<ant antfile="build.xml" target="all" dir="${jni}"/>
</target>
<!-- create source and class jar -->
<target name="all" depends="compile,compile-natives">
<!-- source jar -->
<mkdir dir="${distDir}/sources" />
<!-- FIXME doesn't work for bullet, as this only takes the src/ folder -->
<jar destfile="${distDir}/sources/${jar}-sources.jar" basedir="src"/>
<!-- copy shared libs for desktop -->
<copy failonerror="false" todir="${distDir}">
<fileset dir="${libs}">
<include name="**/*-natives.jar"/>
<exclude name="**/test-natives.jar"/>
</fileset>
</copy>
<!-- copy shared libs for android & ios -->
<copy failonerror="false" todir="${distDir}/arm64-v8a">
<fileset dir="${libs}/arm64-v8a">
<include name="**/*.so"/>
</fileset>
</copy>
<copy failonerror="false" todir="${distDir}/armeabi">
<fileset dir="${libs}/armeabi">
<include name="**/*.so"/>
</fileset>
</copy>
<copy failonerror="false" todir="${distDir}/armeabi-v7a">
<fileset dir="${libs}/armeabi-v7a">
<include name="**/*.so"/>
</fileset>
</copy>
<copy failonerror="false" todir="${distDir}/x86">
<fileset dir="${libs}/x86">
<include name="**/*.so"/>
</fileset>
</copy>
<copy failonerror="false" todir="${distDir}/x86_64">
<fileset dir="${libs}/x86_64">
<include name="**/*.so"/>
</fileset>
</copy>
<copy failonerror="false" todir="${distDir}/ios">
<fileset dir="${libs}/ios32">
<include name="**/*.a"/>
<include name="**/*.a.tvos"/>
</fileset>
</copy>
<!-- class jar -->
<jar destfile="${distDir}/${jar}.jar">
<fileset dir="${target}/java"/>
<fileset refid="resourcefiles"/>
<!-- merge dependencies found in libs/ folder, exclude native, debug and android/gwt jars -->
<zipgroupfileset file="${libs}/*.jar">
<exclude name="*-natives.jar"/>
<exclude name="*-debug.jar"/>
<exclude name="android-*.jar"/>
<exclude name="support-*.jar"/>
<exclude name="robovm-*.jar"/>
<exclude name="gwt*.jar"/>
</zipgroupfileset>
<!-- merge dependencies specified in parent build.xml -->
<zipfileset refid="jarfiles"/>
</jar>
</target>
</project>