OSDN Git Service

Fixed build.
[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                 <mkdir dir="${target}/java" />\r
30                 <!-- need to copy the internal font to target if compiling the gdx core :/ -->\r
31                 <copy failonerror="false" tofile="${target}/java/com/badlogic/gdx/utils/arial-15.png" file="src/com/badlogic/gdx/utils/arial-15.png" />\r
32                 <copy failonerror="false" tofile="${target}/java/com/badlogic/gdx/utils/arial-15.fnt" file="src/com/badlogic/gdx/utils/arial-15.fnt" />\r
33                 <!-- need to copy jni headers for gdx-jnigen -->\r
34                 <copy failonerror="false" todir="${target}/java">\r
35                         <fileset dir="src">\r
36                                 <include name="**/*.h"/>\r
37                                 <include name="**/*.template"/>\r
38                         </fileset>\r
39                 </copy>\r
40         </target>\r
41 \r
42         <!-- compiles the java code -->\r
43         <target name="compile" depends="init">\r
44                 <javac debug="on" srcdir="${src}" destdir="${target}/java">\r
45                         <classpath>\r
46                                 <path refid="classpath"/>\r
47                                 <fileset file="${libs}/*.jar">\r
48                                         <exclude name="*-natives.jar"/>\r
49                                 </fileset>\r
50                         </classpath>\r
51                 </javac>\r
52         </target>\r
53 \r
54 \r
55         <!-- compile native code if available -->\r
56         <target name="check-natives">\r
57                 <condition property="natives-present">\r
58                         <and>\r
59                                 <available file="${jni}/build.xml"/>\r
60                                 <istrue value="${build-natives}"/>\r
61                         </and>\r
62                 </condition>\r
63         </target>\r
64         <target name="compile-natives" depends="init, check-natives" if="natives-present">\r
65                 <echo message="compiling natives code"/>\r
66                 <ant antfile="build.xml" target="clean" dir="${jni}"/>\r
67                 <ant antfile="build.xml" target="all" dir="${jni}"/>\r
68                 <!-- copy shared libs for android -->\r
69                 <copy failonerror="false" todir="${distDir}/armeabi">\r
70                         <fileset dir="${libs}/armeabi">\r
71                                 <include name="**/*.so"/>\r
72                         </fileset>\r
73                 </copy>\r
74                 <copy failonerror="false" todir="${distDir}/armeabi-v7a">\r
75                         <fileset dir="${libs}/armeabi-v7a">\r
76                                 <include name="**/*.so"/>\r
77                         </fileset>\r
78                 </copy>\r
79         </target>\r
80         \r
81         <!-- create source and class jar -->\r
82         <target name="all" depends="compile,compile-natives">\r
83                 <!-- source jar -->\r
84                 <mkdir dir="${distDir}/sources" />\r
85                 <jar destfile="${distDir}/sources/${jar}-sources.jar" basedir="${src}" />\r
86                 \r
87                 <!-- copy shared libs for desktop -->\r
88                 <copy failonerror="false" todir="${distDir}">\r
89                         <fileset dir="${libs}">\r
90                                 <include name="**/*-natives.jar"/>\r
91                                 <exclude name="**/test-natives.jar"/>\r
92                         </fileset>\r
93                 </copy>\r
94                 \r
95                 <!-- copy shared libs for android -->\r
96                 <copy failonerror="false" todir="${distDir}/armeabi">\r
97                         <fileset dir="${libs}/armeabi">\r
98                                 <include name="**/*.so"/>\r
99                         </fileset>\r
100                 </copy>\r
101                 <copy failonerror="false" todir="${distDir}/armeabi-v7a">\r
102                         <fileset dir="${libs}/armeabi-v7a">\r
103                                 <include name="**/*.so"/>\r
104                         </fileset>\r
105                 </copy>\r
106                 \r
107                 <!-- class jar -->\r
108                 <jar destfile="${distDir}/${jar}.jar">\r
109                         <fileset dir="${target}/java"/>\r
110                         <!-- merge dependencies found in libs/ folder, exclude native, debug and android jars -->\r
111                         <zipgroupfileset file="${libs}/*.jar">\r
112                                 <exclude name="*-natives.jar"/>\r
113                                 <exclude name="*-debug.jar"/>\r
114                                 <exclude name="android-*.jar"/>\r
115                         </zipgroupfileset>\r
116                         <!-- merge dependencies specified in parent build.xml -->\r
117                         <zipfileset refid="jarfiles"/>\r
118                 </jar>\r
119         </target>\r
120 </project>\r