/SoundBack/build.xml

http://eyes-free.googlecode.com/ · XML · 269 lines · 209 code · 29 blank · 31 comment · 0 complexity · d4f7e7ebaeebafa066ab4dbc0aa7b540 MD5 · raw file

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