Switched to main osmdroid codebase
[osm-maps-android.git] / build.xml
blobe7c96aaa4b98af8ca02ba78e22b2d1a6145ed033
1 <?xml version="1.0" ?>
2 <project name="MapView" default="debug">
4     <!-- The build.properties file can be created by you and is never touched
5          by activitycreator. If you want to manually set properties, this is
6          the best place to set them. -->
7     <property file="build.properties"/>
9     <!-- The default.properties file is created and updated by activitycreator.
10          It will set any properties not already defined by build.properties. -->
11     <property file="default.properties"/>
13     <!-- ************************************************************************************* -->
14     <!-- These settings were written by activitycreator.
15          Do not change them unless you really know what you are doing. -->
17     <!-- Application Package Name -->
18     <property name="application-package" value="org.technomancy.osm.viewmap" />
20     <!-- The intermediates directory, Eclipse uses "bin"
21          for its own output, so we do the same. -->
22     <property name="outdir" value="bin" />
23     
24     <!-- ************************************************************************************* -->
25     <!-- No user servicable parts below. -->
27     <property name="android-tools" value="${sdk-folder}/tools" />
28     <property name="android-framework" value="${android-tools}/lib/framework.aidl" />
30     <!-- Input directories -->
31     <property name="resource-dir" value="res" />
32     <property name="asset-dir" value="assets" />
33     <property name="srcdir" value="src" />
34     <condition property="srcdir-ospath"
35             value="${basedir}\${srcdir}"
36             else="${basedir}/${srcdir}" >
37         <os family="windows"/>
38     </condition>
40     <!-- folder for the 3rd party java libraries -->
41     <property name="external-libs" value="libs" />
42     <condition property="external-libs-ospath"
43             value="${basedir}\${external-libs}"
44             else="${basedir}/${external-libs}" >
45         <os family="windows"/>
46     </condition>
48     <!-- folder for the native libraries -->
49     <property name="native-libs" value="libs" />
50     <condition property="native-libs-ospath"
51             value="${basedir}\${native-libs}"
52             else="${basedir}/${native-libs}" >
53         <os family="windows"/>
54     </condition>
56     <!-- Output directories -->
57     <property name="outdir-classes" value="${outdir}/classes" />
58     <condition property="outdir-classes-ospath"
59             value="${basedir}\${outdir-classes}"
60             else="${basedir}/${outdir-classes}" >
61         <os family="windows"/>
62     </condition>
64     <!-- Create R.java in the source directory -->
65     <property name="outdir-r" value="src" />
67     <!-- Intermediate files -->
68     <property name="dex-file" value="classes.dex" />
69     <property name="intermediate-dex" value="${outdir}/${dex-file}" />
70     <condition property="intermediate-dex-ospath"
71             value="${basedir}\${intermediate-dex}"
72             else="${basedir}/${intermediate-dex}" >
73         <os family="windows"/>
74     </condition>
76     <!-- The final package file to generate -->
77     <property name="resources-package" value="${outdir}/${ant.project.name}.ap_" />
78     <condition property="resources-package-ospath"
79             value="${basedir}\${resources-package}"
80             else="${basedir}/${resources-package}" >
81         <os family="windows"/>
82     </condition>
84     <property name="out-debug-package" value="${outdir}/${ant.project.name}-debug.apk" />
85     <condition property="out-debug-package-ospath"
86             value="${basedir}\${out-debug-package}"
87             else="${basedir}/${out-debug-package}" >
88         <os family="windows"/>
89     </condition>
91     <property name="out-unsigned-package" value="${outdir}/${ant.project.name}-unsigned.apk" />
92     <condition property="out-unsigned-package-ospath"
93             value="${basedir}\${out-unsigned-package}"
94             else="${basedir}/${out-unsigned-package}" >
95         <os family="windows"/>
96     </condition>
98     <!-- Tools -->
99     <condition property="aapt" value="${android-tools}/aapt.exe" else="${android-tools}/aapt" >
100         <os family="windows"/>
101     </condition>
102     <condition property="aidl" value="${android-tools}/aidl.exe" else="${android-tools}/aidl" >
103         <os family="windows"/>
104     </condition>
105     <condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" >
106         <os family="windows"/>
107     </condition>
108     <condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx" >
109         <os family="windows"/>
110     </condition>
111     <condition property="apk-builder" value="${android-tools}/apkbuilder.bat" else="${android-tools}/apkbuilder" >
112         <os family="windows"/>
113     </condition>
115     <property name="android-jar" value="${sdk-folder}/android.jar" />
117     <!-- Rules -->
119     <!-- Create the output directories if they don't exist yet. -->
120     <target name="dirs">
121         <echo>Creating output directories if needed...</echo>
122         <mkdir dir="${outdir}" />
123         <mkdir dir="${outdir-classes}" />
124     </target>
126     <!-- Generate the R.java file for this project's resources. -->
127     <target name="resource-src" depends="dirs">
128         <echo>Generating R.java / Manifest.java from the resources...</echo>
129         <exec executable="${aapt}" failonerror="true">
130             <arg value="package" />
131             <arg value="-m" />
132             <arg value="-J" />
133             <arg value="${outdir-r}" />
134             <arg value="-M" />
135             <arg value="AndroidManifest.xml" />
136             <arg value="-S" />
137             <arg value="${resource-dir}" />
138             <arg value="-I" />
139             <arg value="${android-jar}" />
140         </exec>
141     </target>
143     <!-- Generate java classes from .aidl files. -->
144     <target name="aidl" depends="dirs">
145         <echo>Compiling aidl files into Java classes...</echo>
146         <apply executable="${aidl}" failonerror="true">
147             <arg value="-p${android-framework}" />
148             <arg value="-I${srcdir}" />
149             <fileset dir="${srcdir}">
150                 <include name="**/*.aidl"/>
151             </fileset>
152         </apply>
153     </target>
155     <!-- Compile this project's .java files into .class files. -->
156     <target name="compile" depends="dirs, resource-src, aidl">
157         <javac encoding="ascii" target="1.5" debug="true" extdirs=""
158                 srcdir="."
159                 destdir="${outdir-classes}"
160                 bootclasspath="${android-jar}">
161             <classpath>
162                 <fileset dir="${external-libs}" includes="*.jar"/>
163             </classpath>
164          </javac>
165     </target>
167     <!-- Convert this project's .class files into .dex files. -->
168     <target name="dex" depends="compile">
169         <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
170         <apply executable="${dx}" failonerror="true" parallel="true">
171             <arg value="--dex" />
172             <arg value="--output=${intermediate-dex-ospath}" />
173             <arg path="${outdir-classes-ospath}" />
174             <fileset dir="${external-libs}" includes="*.jar"/>
175         </apply>
176     </target>
178     <!-- Put the project's resources into the output package file. -->
179     <target name="package-res-and-assets">
180         <echo>Packaging resources and assets...</echo>
181         <exec executable="${aapt}" failonerror="true">
182             <arg value="package" />
183             <arg value="-f" />
184             <arg value="-M" />
185             <arg value="AndroidManifest.xml" />
186             <arg value="-S" />
187             <arg value="${resource-dir}" />
188             <arg value="-A" />
189             <arg value="${asset-dir}" />
190             <arg value="-I" />
191             <arg value="${android-jar}" />
192             <arg value="-F" />
193             <arg value="${resources-package}" />
194         </exec>
195     </target>
197     <!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
198     <target name="package-res-no-assets">
199         <echo>Packaging resources...</echo>
200         <exec executable="${aapt}" failonerror="true">
201             <arg value="package" />
202             <arg value="-f" />
203             <arg value="-M" />
204             <arg value="AndroidManifest.xml" />
205             <arg value="-S" />
206             <arg value="${resource-dir}" />
207             <!-- No assets directory -->
208             <arg value="-I" />
209             <arg value="${android-jar}" />
210             <arg value="-F" />
211             <arg value="${resources-package}" />
212         </exec>
213     </target>
215     <!-- Invoke the proper target depending on whether or not
216          an assets directory is present. -->
217     <!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
218          only when the assets dir exists. -->
219     <target name="package-res">
220         <available file="${asset-dir}" type="dir"
221                 property="res-target" value="and-assets" />
222         <property name="res-target" value="no-assets" />
223         <antcall target="package-res-${res-target}" />
224     </target>
226     <!-- Package the application and sign it with a debug key.
227          This is the default target when building. It is used for debug. -->
228     <target name="debug" depends="dex, package-res">
229         <echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
230         <exec executable="${apk-builder}" failonerror="true">
231             <arg value="${out-debug-package-ospath}" />
232             <arg value="-z" />
233             <arg value="${resources-package-ospath}" />
234             <arg value="-f" />
235             <arg value="${intermediate-dex-ospath}" />
236             <arg value="-rf" />
237             <arg value="${srcdir-ospath}" />
238             <arg value="-rj" />
239             <arg value="${external-libs-ospath}" />
240             <arg value="-nf" />
241             <arg value="${native-libs-ospath}" />
242         </exec>
243     </target>
245     <!-- Package the application without signing it.
246          This allows for the application to be signed later with an official publishing key. -->
247     <target name="release" depends="dex, package-res">
248         <echo>Packaging ${out-unsigned-package} for release...</echo>
249         <exec executable="${apk-builder}" failonerror="true">
250             <arg value="${out-unsigned-package-ospath}" />
251             <arg value="-u" />
252             <arg value="-z" />
253             <arg value="${resources-package-ospath}" />
254             <arg value="-f" />
255             <arg value="${intermediate-dex-ospath}" />
256             <arg value="-rf" />
257             <arg value="${srcdir-ospath}" />
258             <arg value="-rj" />
259             <arg value="${external-libs-ospath}" />
260             <arg value="-nf" />
261             <arg value="${native-libs-ospath}" />
262         </exec>
263         <echo>It will need to be signed with jarsigner before being published.</echo>
264     </target>
266     <!-- Install the package on the default emulator -->
267     <target name="install" depends="debug">
268         <echo>Installing ${out-debug-package} onto default emulator...</echo>
269         <exec executable="${adb}" failonerror="true">
270             <arg value="install" />
271             <arg value="${out-debug-package}" />
272         </exec>
273     </target>
275     <target name="reinstall" depends="debug">
276         <echo>Installing ${out-debug-package} onto default emulator...</echo>
277         <exec executable="${adb}" failonerror="true">
278             <arg value="install" />
279             <arg value="-r" />
280             <arg value="${out-debug-package}" />
281         </exec>
282     </target>
284     <!-- Uinstall the package from the default emulator -->
285     <target name="uninstall">
286         <echo>Uninstalling ${application-package} from the default emulator...</echo>
287         <exec executable="${adb}" failonerror="true">
288             <arg value="uninstall" />
289             <arg value="${application-package}" />
290         </exec>
291     </target>
293 </project>