/[projects]/android/admob/samples/LunarLander/build.xml
ViewVC logotype

Contents of /android/admob/samples/LunarLander/build.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (show annotations) (download) (as text)
Wed Sep 23 12:54:05 2009 UTC (14 years, 8 months ago) by torben
File MIME type: text/xml
File size: 13912 byte(s)
import admob library
1 <?xml version="1.0" ?>
2 <project name="lunarlander" default="debug">
3
4 <!-- ProGuard location -->
5 <property name="proguard.jar" value="../proguard.jar" />
6
7 <!-- SDK Locations -->
8 <property name="android-sdk" value="/usr/local/android" />
9 <property name="android-sdk-1.1" value="${android-sdk}/platforms/android-1.1" />
10 <property name="android-sdk-1.5" value="${android-sdk}/platforms/android-1.5" />
11 <property name="android-tools" value="${android-sdk}/tools" />
12 <property name="android-tools-1.1" value="${android-sdk-1.1}/tools" />
13 <property name="android-tools-1.5" value="${android-sdk-1.5}/tools" />
14 <property name="sdk-folder" value="${android-sdk-1.5}" />
15
16 <!-- Application Package Name -->
17 <property name="application-package" value="com.example.admob.lunarlander" />
18
19 <!-- The intermediates directory -->
20 <!-- Eclipse uses "bin" for its own output, so we do the same. -->
21 <property name="outdir" value="bin" />
22
23 <!-- ************************************************************************************* -->
24 <!-- No user servicable parts below. -->
25
26 <property name="android-framework" value="${android-tools}/lib/framework.aidl" />
27
28 <!-- Input directories -->
29 <property name="resource-dir" value="res" />
30 <property name="asset-dir" value="assets" />
31 <property name="srcdir" value="src" />
32 <condition property="srcdir-ospath"
33 value="${basedir}\${srcdir}"
34 else="${basedir}/${srcdir}" >
35 <os family="windows"/>
36 </condition>
37
38 <property name="gendir" value="gen" />
39 <condition property="gendir-ospath"
40 value="${basedir}\${gendir}"
41 else="${basedir}/${gendir}" >
42 <os family="windows"/>
43 </condition>
44
45 <property name="external-libs" value="libs" />
46 <condition property="external-libs-ospath"
47 value="${basedir}\${external-libs}"
48 else="${basedir}/${external-libs}" >
49 <os family="windows"/>
50 </condition>
51
52 <!-- Output directories -->
53 <property name="outdir-classes" value="${outdir}/classes" />
54 <condition property="outdir-classes-ospath"
55 value="${basedir}\${outdir-classes}"
56 else="${basedir}/${outdir-classes}" >
57 <os family="windows"/>
58 </condition>
59
60 <!-- Create R.java in the source directory -->
61 <property name="outdir-r" value="${gendir}" />
62
63 <!-- Intermediate files -->
64 <property name="dex-file" value="classes.dex" />
65 <property name="intermediate-dex" value="${outdir}/${dex-file}" />
66 <condition property="intermediate-dex-ospath"
67 value="${basedir}\${intermediate-dex}"
68 else="${basedir}/${intermediate-dex}" >
69 <os family="windows"/>
70 </condition>
71
72 <!-- The final package file to generate -->
73 <property name="resources-package" value="${outdir}/${ant.project.name}.ap_" />
74 <condition property="resources-package-ospath"
75 value="${basedir}\${resources-package}"
76 else="${basedir}/${resources-package}" >
77 <os family="windows"/>
78 </condition>
79
80 <property name="out-debug-package" value="${outdir}/${ant.project.name}-debug.apk" />
81 <condition property="out-debug-package-ospath"
82 value="${basedir}\${out-debug-package}"
83 else="${basedir}/${out-debug-package}" >
84 <os family="windows"/>
85 </condition>
86
87 <property name="out-unsigned-package" value="${outdir}/${ant.project.name}-unsigned.apk" />
88 <condition property="out-unsigned-package-ospath"
89 value="${basedir}\${out-unsigned-package}"
90 else="${basedir}/${out-unsigned-package}" >
91 <os family="windows"/>
92 </condition>
93
94 <!-- Tools -->
95 <condition property="aapt" value="${android-tools-1.5}/aapt.exe" else="${android-tools-1.5}/aapt" >
96 <os family="windows"/>
97 </condition>
98 <condition property="aidl" value="${android-tools-1.5}/aidl.exe" else="${android-tools-1.5}/aidl" >
99 <os family="windows"/>
100 </condition>
101 <condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" >
102 <os family="windows"/>
103 </condition>
104 <condition property="dx" value="${android-tools-1.5}/dx.bat" else="${android-tools-1.5}/dx" >
105 <os family="windows"/>
106 </condition>
107 <condition property="apk-builder" value="${android-tools}/apkbuilder.bat" else="${android-tools}/apkbuilder" >
108 <os family="windows"/>
109 </condition>
110
111 <property name="android-jar" value="${sdk-folder}/android.jar" />
112
113 <!-- Rules -->
114
115 <!-- Create the output directories if they don't exist yet. -->
116 <target name="dirs">
117 <echo>Creating output directories if needed...</echo>
118 <mkdir dir="${outdir}" />
119 <mkdir dir="${outdir-classes}" />
120 </target>
121
122 <!-- Generate the R.java file for this project's resources. -->
123 <target name="resource-src" depends="dirs">
124 <echo>Generating R.java / Manifest.java from the resources...</echo>
125 <exec executable="${aapt}" failonerror="true">
126 <arg value="package" />
127 <arg value="-m" />
128 <arg value="-J" />
129 <arg value="${outdir-r}" />
130 <arg value="-M" />
131 <arg value="AndroidManifest.xml" />
132 <arg value="-S" />
133 <arg value="${resource-dir}" />
134 <arg value="-I" />
135 <arg value="${android-jar}" />
136 </exec>
137 </target>
138
139 <!-- Generate java classes from .aidl files. -->
140 <target name="aidl" depends="dirs">
141 <echo>Compiling aidl files into Java classes...</echo>
142 <apply executable="${aidl}" failonerror="true">
143 <arg value="-p${android-framework}" />
144 <arg value="-I${srcdir}" />
145 <fileset dir="${srcdir}">
146 <include name="**/*.aidl"/>
147 </fileset>
148 </apply>
149 </target>
150
151 <!-- Compile this project's .java files into .class files. -->
152 <target name="compile" depends="dirs, resource-src, aidl">
153 <javac encoding="ascii" target="1.5" debug="true" extdirs=""
154 srcdir="."
155 destdir="${outdir-classes}"
156 bootclasspath="${android-jar}">
157 <classpath>
158 <fileset dir="${external-libs}" includes="*.jar"/>
159 </classpath>
160 </javac>
161 </target>
162
163 <!-- Obfuscate the example. -->
164 <!-- Obfuscation makes the the resulting .apk smaller and therefore faster to download from the Market. -->
165 <!-- It also can make the application perform faster, but this is not its main purpose. -->
166 <target name="check-for-proguard">
167 <available property="proguard-available" file="${proguard.jar}" />
168 </target>
169
170 <target name="obfuscate" depends="compile, check-for-proguard" if="proguard-available">
171 <echo>Obfuscating .class files in ${outdir-classes}</echo>
172
173 <!-- Define the .class files to obfuscate -->
174 <path id="classes-to-obfuscate">
175
176 <!-- This project's unobfuscated .class files -->
177 <pathelement path="${outdir-classes}-unobfuscated"/>
178
179 <!-- The admob-sdk-android.jar (which will get obfuscated too) -->
180 <fileset dir="${external-libs}" />
181
182 </path>
183
184
185 <!-- Task definition for the proguard task -->
186 <taskdef resource="proguard/ant/task.properties" classpath="${proguard.jar}" />
187
188 <!-- Temporarily rename the file to obfuscate -->
189 <move file="${outdir-classes}" tofile="${outdir-classes}-unobfuscated" />
190
191 <!-- Obfuscate using ProGuard (http://proguard.sourceforge.net/) -->
192 <!-- Tested with Proguard 4.4 (http://sourceforge.net/projects/proguard/files/) -->
193 <proguard
194 preverify="false"
195 optimize="false"
196 usemixedcaseclassnames="false"
197 allowaccessmodification="true"
198 printmapping="${outdir}/obfuscation_mapping.txt"
199 repackageclasses="">
200
201 <injar refid="classes-to-obfuscate" />
202 <outjar dir="${outdir-classes}" />
203
204 <!-- Include any 3rd party libraries that won't be obfuscated -->
205 <libraryjar>
206 <pathelement location="${sdk-folder}/android.jar" />
207 </libraryjar>
208
209 <!-- Anything specified in AndroidManifest.xml or XML layouts must be exluded from obfuscation here -->
210 <keep access="public" type="class" name="com.example.admob.lunarlander.LunarLander" />
211 <keep type="class" name="com.example.admob.lunarlander.LunarView" />
212 <keep access="public" type="class" name="com.example.admob.lunarlander.R$string">
213 <field name="*" />
214 <method name="*" />
215 </keep>
216
217 <!-- If you create an AdView in an XML layout (i.e. not directly in Java code) do not obfuscate it -->
218 <keep access="public" type="class" name="com.admob.android.ads.AdView" />
219
220 </proguard>
221
222 </target>
223
224 <!-- Convert this project's .class files into .dex files. -->
225 <target name="dex" depends="obfuscate"> <!-- Can depend on the "compile" task to use original, non-obfuscated code -->
226 <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
227 <apply executable="${dx}" failonerror="true" parallel="true">
228 <arg value="--dex" />
229 <arg value="--output=${intermediate-dex-ospath}" />
230 <arg path="${outdir-classes-ospath}" />
231 <fileset dir="${external-libs}" excludes="*" /> <!-- We've obfuscated our includes so made this "excludes" instead of "includes" -->
232 </apply>
233 </target>
234
235 <!-- Put the project's resources into the output package file. -->
236 <target name="package-res-and-assets">
237 <echo>Packaging resources and assets...</echo>
238 <exec executable="${aapt}" failonerror="true">
239 <arg value="package" />
240 <arg value="-f" />
241 <arg value="-M" />
242 <arg value="AndroidManifest.xml" />
243 <arg value="-S" />
244 <arg value="${resource-dir}" />
245 <arg value="-A" />
246 <arg value="${asset-dir}" />
247 <arg value="-I" />
248 <arg value="${android-jar}" />
249 <arg value="-F" />
250 <arg value="${resources-package}" />
251 </exec>
252 </target>
253
254 <!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
255 <target name="package-res-no-assets">
256 <echo>Packaging resources...</echo>
257 <exec executable="${aapt}" failonerror="true">
258 <arg value="package" />
259 <arg value="-f" />
260 <arg value="-M" />
261 <arg value="AndroidManifest.xml" />
262 <arg value="-S" />
263 <arg value="${resource-dir}" />
264 <!-- No assets directory -->
265 <arg value="-I" />
266 <arg value="${android-jar}" />
267 <arg value="-F" />
268 <arg value="${resources-package}" />
269 </exec>
270 </target>
271
272 <!-- Invoke the proper target depending on whether or not
273 an assets directory is present. -->
274 <!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
275 only when the assets dir exists. -->
276 <target name="package-res">
277 <available file="${asset-dir}" type="dir"
278 property="res-target" value="and-assets" />
279 <property name="res-target" value="no-assets" />
280 <antcall target="package-res-${res-target}" />
281 </target>
282
283 <!-- Package the application and sign it with a debug key.
284 This is the default target when building. It is used for debug. -->
285 <target name="debug" depends="dex, package-res">
286 <echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
287 <exec executable="${apk-builder}" failonerror="true">
288 <arg value="${out-debug-package-ospath}" />
289 <arg value="-z" />
290 <arg value="${resources-package-ospath}" />
291 <arg value="-f" />
292 <arg value="${intermediate-dex-ospath}" />
293 <arg value="-rf" />
294 <arg value="${srcdir-ospath}" />
295 <arg value="-rj" />
296 <arg value="${external-libs-ospath}" />
297 </exec>
298 </target>
299
300 <!-- Package the application without signing it.
301 This allows for the application to be signed later with an official publishing key. -->
302 <target name="release" depends="dex, package-res">
303 <echo>Packaging ${out-unsigned-package} for release...</echo>
304 <exec executable="${apk-builder}" failonerror="true">
305 <arg value="${out-unsigned-package-ospath}" />
306 <arg value="-u" />
307 <arg value="-z" />
308 <arg value="${resources-package-ospath}" />
309 <arg value="-f" />
310 <arg value="${intermediate-dex-ospath}" />
311 <arg value="-rf" />
312 <arg value="${srcdir-ospath}" />
313 <arg value="-rj" />
314 <arg value="${external-libs-ospath}" />
315 </exec>
316 <echo>It will need to be signed with jarsigner before being published.</echo>
317 </target>
318
319 <!-- Install the package on the default emulator -->
320 <target name="install" depends="debug">
321 <echo>Installing ${out-debug-package} onto default emulator...</echo>
322 <exec executable="${adb}" failonerror="true">
323 <arg value="install" />
324 <arg value="${out-debug-package}" />
325 </exec>
326 </target>
327
328 <target name="reinstall" depends="debug">
329 <echo>Installing ${out-debug-package} onto default emulator...</echo>
330 <exec executable="${adb}" failonerror="true">
331 <arg value="install" />
332 <arg value="-r" />
333 <arg value="${out-debug-package}" />
334 </exec>
335 </target>
336
337 <!-- Uinstall the package from the default emulator -->
338 <target name="uninstall">
339 <echo>Uninstalling ${application-package} from the default emulator...</echo>
340 <exec executable="${adb}" failonerror="true">
341 <arg value="uninstall" />
342 <arg value="${application-package}" />
343 </exec>
344 </target>
345
346 </project>

  ViewVC Help
Powered by ViewVC 1.1.20