PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/KickBack/build.xml

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