1 <!-- 2 template Ant build file for all projects that should go into the distribution. 3 Fill out the properties at the beginning of the project definition. 4 5 The following things have to be set from the outside: 6 7 property name="jar" value="jar-name-without-suffix" -> the name of the resulting jar file 8 property name="distDir" value="dist-directory" -> the output directory for the resulting jar 9 path id="classpath" -> the filesets defining the classpath needed to compile the project 10 zipfileset id="jarfiles" -> the jar files to be merged with the project's classes 11 --> 12 <project name="template" default="all" basedir="."> 13 <!-- default values --> 14 <path id="src"> 15 <pathelement location="src"/> 16 </path> 17 <path id="classpath"/> 18 <property name="jni" value="jni"/> 19 <property name="target" value="target" /> 20 <property name="libs" value="libs" /> 21 <zipfileset id="jarfiles" dir="." excludes="**"/> 22 <fileset id="resourcefiles" dir="." excludes="**"/> 23 24 <!-- clean output directories, create libs directory --> 25 <target name="clean"> 26 <mkdir dir="${libs}" /> 27 <delete dir="${target}" /> 28 </target> 29 30 <!-- init task, creates all necessary directories --> 31 <target name="init" depends="clean"> 32 <mkdir dir="${target}" /> 33 <mkdir dir="${target}/java" /> 34 <!-- need to copy jni headers for gdx-jnigen --> 35 <copy failonerror="false" todir="${target}/java"> 36 <fileset dir="src"> 37 <include name="**/*.h"/> 38 <include name="**/*.template"/> 39 </fileset> 40 </copy> 41 <copy failonerror="false" todir="${target}/java"> 42 <fileset dir="src"> 43 <include name="**/*.gwt.xml"/> 44 </fileset> 45 </copy> 46 </target> 47 48 <!-- compiles the java code --> 49 <target name="compile" depends="init"> 50 <javac debug="on" encoding="utf-8" source="1.6" target="1.6" destdir="${target}/java" includeantruntime="false"> 51 <src> 52 <path refid="src"/> 53 </src> 54 <classpath> 55 <path refid="classpath"/> 56 <fileset file="${libs}/*.jar"> 57 <exclude name="*-natives.jar"/> 58 </fileset> 59 </classpath> 60 <exclude name="**/gwt/emu/java/lang/System.java"/> 61 </javac> 62 </target> 63 64 65 <!-- compile native code if available --> 66 <target name="check-natives"> 67 <condition property="natives-present"> 68 <and> 69 <available file="${jni}/build.xml"/> 70 <istrue value="${build-natives}"/> 71 </and> 72 </condition> 73 </target> 74 75 <target name="compile-natives" depends="init, check-natives" if="natives-present"> 76 <mkdir dir="${libs}/android32" /> 77 <mkdir dir="{libs}/arm64-v8a" /> 78 <mkdir dir="${libs}/armeabi" /> 79 <mkdir dir="${libs}/armeabi-v7a" /> 80 <mkdir dir="${libs}/x86" /> 81 <mkdir dir="${libs}/x86_64" /> 82 <mkdir dir="${libs}/linux32" /> 83 <mkdir dir="${libs}/linux64" /> 84 <mkdir dir="${libs}/macosx32" /> 85 <mkdir dir="${libs}/macosx64" /> 86 <mkdir dir="${libs}/windows32" /> 87 <mkdir dir="${libs}/windows64" /> 88 <mkdir dir="${libs}/ios32"/> 89 <echo message="compiling natives code"/> 90 <ant antfile="build.xml" target="clean" dir="${jni}"/> 91 <ant antfile="build.xml" target="all" dir="${jni}"/> 92 </target> 93 94 <!-- create source and class jar --> 95 <target name="all" depends="compile,compile-natives"> 96 <!-- source jar --> 97 <mkdir dir="${distDir}/sources" /> 98 99 <!-- FIXME doesn't work for bullet, as this only takes the src/ folder --> 100 <jar destfile="${distDir}/sources/${jar}-sources.jar" basedir="src"/> 101 102 <!-- copy shared libs for desktop --> 103 <copy failonerror="false" todir="${distDir}"> 104 <fileset dir="${libs}"> 105 <include name="**/*-natives.jar"/> 106 <exclude name="**/test-natives.jar"/> 107 </fileset> 108 </copy> 109 110 <!-- copy shared libs for android & ios --> 111 <copy failonerror="false" todir="${distDir}/arm64-v8a"> 112 <fileset dir="${libs}/arm64-v8a"> 113 <include name="**/*.so"/> 114 </fileset> 115 </copy> 116 <copy failonerror="false" todir="${distDir}/armeabi"> 117 <fileset dir="${libs}/armeabi"> 118 <include name="**/*.so"/> 119 </fileset> 120 </copy> 121 <copy failonerror="false" todir="${distDir}/armeabi-v7a"> 122 <fileset dir="${libs}/armeabi-v7a"> 123 <include name="**/*.so"/> 124 </fileset> 125 </copy> 126 <copy failonerror="false" todir="${distDir}/x86"> 127 <fileset dir="${libs}/x86"> 128 <include name="**/*.so"/> 129 </fileset> 130 </copy> 131 <copy failonerror="false" todir="${distDir}/x86_64"> 132 <fileset dir="${libs}/x86_64"> 133 <include name="**/*.so"/> 134 </fileset> 135 </copy> 136 <copy failonerror="false" todir="${distDir}/ios"> 137 <fileset dir="${libs}/ios32"> 138 <include name="**/*.a"/> 139 <include name="**/*.a.tvos"/> 140 </fileset> 141 </copy> 142 143 <!-- class jar --> 144 <jar destfile="${distDir}/${jar}.jar"> 145 <fileset dir="${target}/java"/> 146 <fileset refid="resourcefiles"/> 147 <!-- merge dependencies found in libs/ folder, exclude native, debug and android/gwt jars --> 148 <zipgroupfileset file="${libs}/*.jar"> 149 <exclude name="*-natives.jar"/> 150 <exclude name="*-debug.jar"/> 151 <exclude name="android-*.jar"/> 152 <exclude name="support-*.jar"/> 153 <exclude name="robovm-*.jar"/> 154 <exclude name="gwt*.jar"/> 155 </zipgroupfileset> 156 <!-- merge dependencies specified in parent build.xml --> 157 <zipfileset refid="jarfiles"/> 158 </jar> 159 </target> 160 </project> 161