/WhereAbout/build.xml

http://eyes-free.googlecode.com/ · XML · 277 lines · 217 code · 29 blank · 31 comment · 0 complexity · 22510c4b064b6f70d896fd8b8884421a MD5 · raw file

  1. <?xml version="1.0" ?>
  2. <project name="WhereAbout" default="reinstall">
  3. <!-- SDK Locations -->
  4. <property name="sdk-folder" value="C:\eclipse\android-sdk-windows-1.1_r1" />
  5. <condition property="android-tools"
  6. value="${sdk-folder}\tools"
  7. else="${sdk-folder}/tools" >
  8. <os family="windows"/>
  9. </condition>
  10. <!-- Application Package Name -->
  11. <property name="application-package" value="com.google.marvin.whereabout" />
  12. <!-- The intermediates directory -->
  13. <!-- Eclipse uses "bin" for its own output, so we do the same. -->
  14. <property name="outdir" value="bin" />
  15. <!-- ************************************************************************************* -->
  16. <!-- No user servicable parts below. -->
  17. <property name="android-framework" value="${android-tools}/lib/framework.aidl" />
  18. <!-- Input directories -->
  19. <property name="resource-dir" value="res" />
  20. <property name="asset-dir" value="assets" />
  21. <property name="srcdir" value="src" />
  22. <condition property="srcdir-ospath"
  23. value="${basedir}\${srcdir}"
  24. else="${basedir}/${srcdir}" >
  25. <os family="windows"/>
  26. </condition>
  27. <condition property="external-libs"
  28. value="..\commonlibs"
  29. else="../commonlibs" >
  30. <os family="windows"/>
  31. </condition>
  32. <condition property="external-libs-ospath"
  33. value="${basedir}\${external-libs}"
  34. else="${basedir}/${external-libs}" >
  35. <os family="windows"/>
  36. </condition>
  37. <!-- Output directories -->
  38. <property name="outdir-classes" value="${outdir}/classes" />
  39. <condition property="outdir-classes-ospath"
  40. value="${basedir}\${outdir-classes}"
  41. else="${basedir}/${outdir-classes}" >
  42. <os family="windows"/>
  43. </condition>
  44. <!-- Create R.java in the source directory -->
  45. <property name="outdir-r" value="src" />
  46. <!-- Intermediate files -->
  47. <property name="dex-file" value="classes.dex" />
  48. <property name="intermediate-dex" value="${outdir}/${dex-file}" />
  49. <condition property="intermediate-dex-ospath"
  50. value="${basedir}\${intermediate-dex}"
  51. else="${basedir}/${intermediate-dex}" >
  52. <os family="windows"/>
  53. </condition>
  54. <!-- The final package file to generate -->
  55. <property name="resources-package" value="${outdir}/${ant.project.name}.ap_" />
  56. <condition property="resources-package-ospath"
  57. value="${basedir}\${resources-package}"
  58. else="${basedir}/${resources-package}" >
  59. <os family="windows"/>
  60. </condition>
  61. <property name="out-debug-package" value="${outdir}/${ant.project.name}-debug.apk" />
  62. <condition property="out-debug-package-ospath"
  63. value="${basedir}\${out-debug-package}"
  64. else="${basedir}/${out-debug-package}" >
  65. <os family="windows"/>
  66. </condition>
  67. <property name="out-unsigned-package" value="${outdir}/${ant.project.name}-unsigned.apk" />
  68. <condition property="out-unsigned-package-ospath"
  69. value="${basedir}\${out-unsigned-package}"
  70. else="${basedir}/${out-unsigned-package}" >
  71. <os family="windows"/>
  72. </condition>
  73. <!-- Tools -->
  74. <condition property="aapt" value="${android-tools}/aapt.exe" else="${android-tools}/aapt" >
  75. <os family="windows"/>
  76. </condition>
  77. <condition property="aidl" value="${android-tools}/aidl.exe" else="${android-tools}/aidl" >
  78. <os family="windows"/>
  79. </condition>
  80. <condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" >
  81. <os family="windows"/>
  82. </condition>
  83. <condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx" >
  84. <os family="windows"/>
  85. </condition>
  86. <condition property="apk-builder" value="${android-tools}/apkbuilder.bat" else="${android-tools}/apkbuilder" >
  87. <os family="windows"/>
  88. </condition>
  89. <property name="android-jar" value="${sdk-folder}/android.jar" />
  90. <!-- Rules -->
  91. <!-- Create the output directories if they don't exist yet. -->
  92. <target name="dirs">
  93. <echo>Creating output directories if needed...</echo>
  94. <mkdir dir="${outdir}" />
  95. <mkdir dir="${outdir-classes}" />
  96. </target>
  97. <!-- Generate the R.java file for this project's resources. -->
  98. <target name="resource-src" depends="dirs">
  99. <echo>Generating R.java / Manifest.java from the resources...</echo>
  100. <exec executable="${aapt}" failonerror="true">
  101. <arg value="package" />
  102. <arg value="-m" />
  103. <arg value="-J" />
  104. <arg value="${outdir-r}" />
  105. <arg value="-M" />
  106. <arg value="AndroidManifest.xml" />
  107. <arg value="-S" />
  108. <arg value="${resource-dir}" />
  109. <arg value="-I" />
  110. <arg value="${android-jar}" />
  111. </exec>
  112. </target>
  113. <!-- Generate java classes from .aidl files. -->
  114. <target name="aidl" depends="dirs">
  115. <echo>Compiling aidl files into Java classes...</echo>
  116. <apply executable="${aidl}" failonerror="true">
  117. <arg value="-p${android-framework}" />
  118. <arg value="-I${srcdir}" />
  119. <fileset dir="${srcdir}">
  120. <include name="**/*.aidl"/>
  121. </fileset>
  122. </apply>
  123. </target>
  124. <!-- Compile this project's .java files into .class files. -->
  125. <target name="compile" depends="dirs, resource-src, aidl">
  126. <javac encoding="ascii" target="1.5" debug="true" extdirs=""
  127. srcdir="."
  128. destdir="${outdir-classes}"
  129. bootclasspath="${android-jar}">
  130. <classpath>
  131. <fileset dir="${external-libs}" includes="*.jar"/>
  132. </classpath>
  133. </javac>
  134. </target>
  135. <!-- Convert this project's .class files into .dex files. -->
  136. <target name="dex" depends="compile">
  137. <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
  138. <apply executable="${dx}" failonerror="true" parallel="true">
  139. <arg value="--dex" />
  140. <arg value="--output=${intermediate-dex-ospath}" />
  141. <arg path="${outdir-classes-ospath}" />
  142. <fileset dir="${external-libs}" includes="*.jar"/>
  143. </apply>
  144. </target>
  145. <!-- Put the project's resources into the output package file. -->
  146. <target name="package-res-and-assets">
  147. <echo>Packaging resources and assets...</echo>
  148. <exec executable="${aapt}" failonerror="true">
  149. <arg value="package" />
  150. <arg value="-f" />
  151. <arg value="-M" />
  152. <arg value="AndroidManifest.xml" />
  153. <arg value="-S" />
  154. <arg value="${resource-dir}" />
  155. <arg value="-A" />
  156. <arg value="${asset-dir}" />
  157. <arg value="-I" />
  158. <arg value="${android-jar}" />
  159. <arg value="-F" />
  160. <arg value="${resources-package}" />
  161. </exec>
  162. </target>
  163. <!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
  164. <target name="package-res-no-assets">
  165. <echo>Packaging resources...</echo>
  166. <exec executable="${aapt}" failonerror="true">
  167. <arg value="package" />
  168. <arg value="-f" />
  169. <arg value="-M" />
  170. <arg value="AndroidManifest.xml" />
  171. <arg value="-S" />
  172. <arg value="${resource-dir}" />
  173. <!-- No assets directory -->
  174. <arg value="-I" />
  175. <arg value="${android-jar}" />
  176. <arg value="-F" />
  177. <arg value="${resources-package}" />
  178. </exec>
  179. </target>
  180. <!-- Invoke the proper target depending on whether or not
  181. an assets directory is present. -->
  182. <!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
  183. only when the assets dir exists. -->
  184. <target name="package-res">
  185. <available file="${asset-dir}" type="dir"
  186. property="res-target" value="and-assets" />
  187. <property name="res-target" value="no-assets" />
  188. <antcall target="package-res-${res-target}" />
  189. </target>
  190. <!-- Package the application and sign it with a debug key.
  191. This is the default target when building. It is used for debug. -->
  192. <target name="debug" depends="dex, package-res">
  193. <echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
  194. <exec executable="${apk-builder}" failonerror="true">
  195. <arg value="${out-debug-package-ospath}" />
  196. <arg value="-z" />
  197. <arg value="${resources-package-ospath}" />
  198. <arg value="-f" />
  199. <arg value="${intermediate-dex-ospath}" />
  200. <arg value="-rf" />
  201. <arg value="${srcdir-ospath}" />
  202. <arg value="-rj" />
  203. <arg value="${external-libs-ospath}" />
  204. </exec>
  205. </target>
  206. <!-- Package the application without signing it.
  207. This allows for the application to be signed later with an official publishing key. -->
  208. <target name="release" depends="dex, package-res">
  209. <echo>Packaging ${out-unsigned-package} for release...</echo>
  210. <exec executable="${apk-builder}" failonerror="true">
  211. <arg value="${out-unsigned-package-ospath}" />
  212. <arg value="-u" />
  213. <arg value="-z" />
  214. <arg value="${resources-package-ospath}" />
  215. <arg value="-f" />
  216. <arg value="${intermediate-dex-ospath}" />
  217. <arg value="-rf" />
  218. <arg value="${srcdir-ospath}" />
  219. <arg value="-rj" />
  220. <arg value="${external-libs-ospath}" />
  221. </exec>
  222. <echo>It will need to be signed with jarsigner before being published.</echo>
  223. </target>
  224. <!-- Install the package on the default emulator -->
  225. <target name="install" depends="debug">
  226. <echo>Installing ${out-debug-package} onto default emulator...</echo>
  227. <exec executable="${adb}" failonerror="true">
  228. <arg value="install" />
  229. <arg value="${out-debug-package}" />
  230. </exec>
  231. </target>
  232. <target name="reinstall" depends="debug">
  233. <echo>Installing ${out-debug-package} onto default emulator...</echo>
  234. <exec executable="${adb}" failonerror="true">
  235. <arg value="install" />
  236. <arg value="-r" />
  237. <arg value="${out-debug-package}" />
  238. </exec>
  239. </target>
  240. <!-- Uinstall the package from the default emulator -->
  241. <target name="uninstall">
  242. <echo>Uninstalling ${application-package} from the default emulator...</echo>
  243. <exec executable="${adb}" failonerror="true">
  244. <arg value="uninstall" />
  245. <arg value="${application-package}" />
  246. </exec>
  247. </target>
  248. </project>