OSDN Git Service

(no commit message)
[mikumikustudio/libgdx-mikumikustudio.git] / build-template.xml
1 <!-- \r
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
4 \r
5 The following things have to be set from the outside:\r
6 \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
11 -->\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
20         \r
21         <!-- clean output directories -->       \r
22         <target name="clean">           \r
23                 <delete dir="${target}" />\r
24         </target>\r
25 \r
26         <!-- init task, creates all necessary directories -->\r
27         <target name="init" depends="clean">\r
28                 <mkdir dir="${target}" />\r
29                 <!-- need to copy the internal font to target if compiling the gdx core :/ -->\r
30                 <copy failonerror="false" tofile="${target}/com/badlogic/gdx/utils/arial-15.png" file="src/com/badlogic/gdx/utils/arial-15.png" />\r
31                 <copy failonerror="false" tofile="${target}/com/badlogic/gdx/utils/arial-15.fnt" file="src/com/badlogic/gdx/utils/arial-15.fnt" />\r
32                 <!-- need to copy jni headers for gdx-jnigen -->\r
33                 <copy failonerror="false" todir="${target}">\r
34                         <fileset dir="src">\r
35                                 <include name="**/*.h"/>\r
36                                 <include name="**/*.template"/>\r
37                         </fileset>\r
38                 </copy>\r
39         </target>\r
40 \r
41         <!-- compiles the java code -->\r
42         <target name="compile" depends="init">\r
43                 <javac debug="on" srcdir="${src}" destdir="${target}">\r
44                         <classpath>\r
45                                 <path refid="classpath"/>\r
46                                 <fileset file="${libs}/*.jar">\r
47                                         <exclude name="*-natives.jar"/>\r
48                                 </fileset>\r
49                         </classpath>\r
50                 </javac>\r
51         </target>\r
52 \r
53 \r
54         <!-- compile native code if available -->\r
55         <target name="check-natives">\r
56                 <condition property="natives-present">\r
57                         <and>\r
58                                 <available file="${jni}/build.xml"/>\r
59                                 <istrue value="${build-natives}"/>\r
60                         </and>\r
61                 </condition>\r
62         </target>\r
63         <target name="compile-natives" depends="init, check-natives" if="natives-present">\r
64                 <echo message="compiling natives code"/>\r
65                 <ant antfile="build.xml" target="clean" dir="${jni}"/>\r
66                 <ant antfile="build.xml" target="all" dir="${jni}"/>\r
67                 <!-- copy shared libs for android -->\r
68                 <copy failonerror="false" todir="${distDir}/armeabi">\r
69                         <fileset dir="${libs}/armeabi">\r
70                                 <include name="**/*.so"/>\r
71                         </fileset>\r
72                 </copy>\r
73                 <copy failonerror="false" todir="${distDir}/armeabi-v7a">\r
74                         <fileset dir="${libs}/armeabi-v7a">\r
75                                 <include name="**/*.so"/>\r
76                         </fileset>\r
77                 </copy>\r
78         </target>\r
79         \r
80         <!-- create source and class jar -->\r
81         <target name="all" depends="compile,compile-natives">\r
82                 <!-- source jar -->\r
83                 <jar destfile="${distDir}/sources/${jar}-sources.jar" basedir="${src}" />\r
84                 \r
85                 <!-- copy shared libs for desktop -->\r
86                 <copy failonerror="false" file="${libs}/${jar}-natives.jar" tofile="${distDir}/${jar}-natives.jar"/>\r
87                 \r
88                 <!-- class jar -->\r
89                 <jar destfile="${distDir}/${jar}.jar">\r
90                         <fileset dir="${target}">\r
91                                 <exclude name="**/native/**"/>\r
92                         </fileset>\r
93                         <!-- merge dependencies found in libs/ folder, exclude native, debug and android jars -->\r
94                         <zipgroupfileset file="${libs}/*.jar">\r
95                                 <exclude name="*-natives.jar"/>\r
96                                 <exclude name="*-debug.jar"/>\r
97                                 <exclude name="android-*.jar"/>\r
98                         </zipgroupfileset>\r
99                         <!-- merge dependencies specified in parent build.xml -->\r
100                         <zipfileset refid="jarfiles"/>\r
101                 </jar>\r
102         </target>\r
103 </project>\r