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