PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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