Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
84 | ligi | 1 | <?xml version="1.0" ?> |
129 | ligi | 2 | <project name="DUBwise" default="debug"> |
3 | <!-- SDK Locations --> |
||
4 | <property name="sdk-folder" value="/home/ligi/bin/android-sdk-linux_x86-0.9_beta" /> |
||
5 | <property name="android-tools" value="/home/ligi/bin/android-sdk-linux_x86-0.9_beta/tools" /> |
||
6 | |||
7 | <!-- Application Package Name --> |
||
8 | <property name="application-package" value="org.ligi" /> |
||
84 | ligi | 9 | |
10 | <!-- The intermediates directory --> |
||
11 | <!-- Eclipse uses "bin" for its own output, so we do the same. --> |
||
12 | <property name="outdir" value="bin" /> |
||
129 | ligi | 13 | |
14 | <!-- ************************************************************************************* --> |
||
84 | ligi | 15 | <!-- No user servicable parts below. --> |
16 | |||
129 | ligi | 17 | <property name="android-framework" value="${android-tools}/lib/framework.aidl" /> |
18 | |||
84 | ligi | 19 | <!-- Input directories --> |
20 | <property name="resource-dir" value="res" /> |
||
21 | <property name="asset-dir" value="assets" /> |
||
22 | <property name="srcdir" value="src" /> |
||
129 | ligi | 23 | <condition property="srcdir-ospath" |
24 | value="${basedir}\${srcdir}" |
||
25 | else="${basedir}/${srcdir}" > |
||
26 | <os family="windows"/> |
||
27 | </condition> |
||
84 | ligi | 28 | |
129 | ligi | 29 | <property name="external-libs" value="libs" /> |
30 | <condition property="external-libs-ospath" |
||
31 | value="${basedir}\${external-libs}" |
||
32 | else="${basedir}/${external-libs}" > |
||
33 | <os family="windows"/> |
||
34 | </condition> |
||
35 | |||
84 | ligi | 36 | <!-- Output directories --> |
37 | <property name="outdir-classes" value="${outdir}/classes" /> |
||
129 | ligi | 38 | <condition property="outdir-classes-ospath" |
39 | value="${basedir}\${outdir-classes}" |
||
40 | else="${basedir}/${outdir-classes}" > |
||
41 | <os family="windows"/> |
||
42 | </condition> |
||
84 | ligi | 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}" /> |
||
129 | ligi | 50 | <condition property="intermediate-dex-ospath" |
51 | value="${basedir}\${intermediate-dex}" |
||
52 | else="${basedir}/${intermediate-dex}" > |
||
53 | <os family="windows"/> |
||
54 | </condition> |
||
84 | ligi | 55 | |
56 | <!-- The final package file to generate --> |
||
129 | ligi | 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> |
||
84 | ligi | 63 | |
129 | ligi | 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 | |||
84 | ligi | 78 | <!-- Tools --> |
129 | ligi | 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 | |||
84 | ligi | 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"> |
||
129 | ligi | 101 | <echo>Creating output directories if needed...</echo> |
84 | ligi | 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"> |
||
129 | ligi | 108 | <echo>Generating R.java / Manifest.java from the resources...</echo> |
84 | ligi | 109 | <exec executable="${aapt}" failonerror="true"> |
129 | ligi | 110 | <arg value="package" /> |
84 | ligi | 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"> |
||
129 | ligi | 125 | <echo>Compiling aidl files into Java classes...</echo> |
84 | ligi | 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}" |
||
129 | ligi | 140 | bootclasspath="${android-jar}"> |
141 | <classpath> |
||
142 | <fileset dir="${external-libs}" includes="*.jar"/> |
||
143 | </classpath> |
||
144 | </javac> |
||
84 | ligi | 145 | </target> |
146 | |||
147 | <!-- Convert this project's .class files into .dex files. --> |
||
148 | <target name="dex" depends="compile"> |
||
129 | ligi | 149 | <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo> |
150 | <apply executable="${dx}" failonerror="true" parallel="true"> |
||
84 | ligi | 151 | <arg value="--dex" /> |
129 | ligi | 152 | <arg value="--output=${intermediate-dex-ospath}" /> |
153 | <arg path="${outdir-classes-ospath}" /> |
||
154 | <fileset dir="${external-libs}" includes="*.jar"/> |
||
155 | </apply> |
||
84 | ligi | 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}" /> |
||
129 | ligi | 172 | <arg value="-F" /> |
173 | <arg value="${resources-package}" /> |
||
84 | ligi | 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}" /> |
||
129 | ligi | 190 | <arg value="-F" /> |
191 | <arg value="${resources-package}" /> |
||
84 | ligi | 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 | |||
129 | ligi | 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> |
||
84 | ligi | 221 | </target> |
222 | |||
129 | ligi | 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}" /> |
||
84 | ligi | 238 | </exec> |
129 | ligi | 239 | <echo>It will need to be signed with jarsigner before being published.</echo> |
84 | ligi | 240 | </target> |
241 | |||
129 | ligi | 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> |
||
84 | ligi | 250 | |
129 | ligi | 251 | <target name="reinstall" depends="debug"> |
252 | <echo>Installing ${out-debug-package} onto default emulator...</echo> |
||
84 | ligi | 253 | <exec executable="${adb}" failonerror="true"> |
254 | <arg value="install" /> |
||
129 | ligi | 255 | <arg value="-r" /> |
256 | <arg value="${out-debug-package}" /> |
||
84 | ligi | 257 | </exec> |
258 | </target> |
||
259 | |||
129 | ligi | 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 | |||
84 | ligi | 269 | </project> |