Biiig standardization of whitespace. 2 space indents now, no tabs.
[zxing.git] / android / build.xml
1 <?xml version="1.0" ?>
2
3 <!--
4  Copyright (C) 2008 Google Inc.
5
6  Licensed under the Apache License, Version 2.0 (the "License");
7  you may not use this file except in compliance with the License.
8  You may obtain a copy of the License at
9
10       http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17  -->
18
19 <!-- This is a mildly hacked version of the auto-generated project
20      build.xml file. -->
21 <project name="BarcodeReader" default="package">
22   <property file="../build.properties"/>
23   <property name="sdk-folder" value="${android-home}"/>
24   <property name="android-tools" value="${sdk-folder}/tools"/>
25
26   <!-- The intermediates directory -->
27   <!-- Eclipse uses "bin" for its own output, so we do the same. -->
28   <property name="outdir" value="bin"/>
29
30   <!-- No user servicable parts below. -->
31
32   <!-- Input directories -->
33   <property name="resource-dir" value="res"/>
34   <property name="asset-dir" value="assets"/>
35   <property name="srcdir" value="src"/>
36
37   <!-- Output directories -->
38   <property name="outdir-classes" value="${outdir}/classes"/>
39
40   <!-- Create R.java in the source directory -->
41   <property name="outdir-r" value="src"/>
42
43   <!-- Intermediate files -->
44   <property name="dex-file" value="classes.dex"/>
45   <property name="intermediate-dex" value="${outdir}/${dex-file}"/>
46
47   <!-- The final package file to generate -->
48   <property name="out-package" value="${outdir}/${ant.project.name}.apk"/>
49
50   <!-- Tools -->
51   <property name="aapt" value="${android-tools}/aapt"/>
52   <property name="aidl" value="${android-tools}/aidl"/>
53   <property name="dx" value="${android-tools}/dx"/>
54   <property name="zip" value="zip"/>
55   <property name="android-jar" value="${sdk-folder}/android.jar"/>
56
57   <!-- Rules -->
58
59   <target name="init">
60     <tstamp/>
61     <fail message="Please set 'android-home' in build.properties">
62       <condition>
63         <not>
64           <available file="${android-home}" type="dir"/>
65         </not>
66       </condition>
67     </fail>
68     <fail message="Please build 'core' first">
69       <condition>
70         <not>
71           <available file="../core/core.jar" type="file"/>
72         </not>
73       </condition>
74     </fail>
75   </target>
76
77   <!-- Create the output directories if they don't exist yet. -->
78   <target name="dirs">
79     <mkdir dir="${outdir}"/>
80     <mkdir dir="${outdir-classes}"/>
81   </target>
82
83   <!-- Generate the R.java file for this project's resources. -->
84   <target name="resource-src" depends="dirs">
85     <echo>Generating R.java...</echo>
86     <exec executable="${aapt}" failonerror="true">
87       <arg value="compile"/>
88       <arg value="-m"/>
89       <arg value="-J"/>
90       <arg value="${outdir-r}"/>
91       <arg value="-M"/>
92       <arg value="AndroidManifest.xml"/>
93       <arg value="-S"/>
94       <arg value="${resource-dir}"/>
95       <arg value="-I"/>
96       <arg value="${android-jar}"/>
97     </exec>
98   </target>
99
100   <!-- Generate java classes from .aidl files. -->
101   <target name="aidl" depends="dirs">
102     <apply executable="${aidl}" failonerror="true">
103       <fileset dir="${srcdir}">
104         <include name="**/*.aidl"/>
105       </fileset>
106     </apply>
107   </target>
108
109   <!-- Compile this project's .java files into .class files. -->
110   <target name="compile" depends="init, dirs, resource-src, aidl">
111     <javac encoding="ascii" target="1.5" debug="true" extdirs=""
112            srcdir="."
113            destdir="${outdir-classes}"
114            bootclasspath="${android-jar}">
115       <classpath>
116         <pathelement location="../core/core.jar"/>
117       </classpath>
118     </javac>
119     <unzip src="../core/core.jar" dest="${outdir-classes}"/>
120   </target>
121
122   <!-- Convert this project's .class files into .dex files. -->
123   <target name="dex" depends="compile">
124     <exec executable="${dx}" failonerror="true">
125       <arg value="-JXmx384M"/>
126       <arg value="--dex"/>
127       <arg value="--output=${intermediate-dex}"/>
128       <arg value="--locals=full"/>
129       <arg value="--positions=lines"/>
130       <arg path="${outdir-classes}"/>
131     </exec>
132   </target>
133
134   <!-- Put the project's resources into the output package file. -->
135   <target name="package-res-and-assets">
136     <echo>Packaging resources and assets...</echo>
137     <exec executable="${aapt}" failonerror="true">
138       <arg value="package"/>
139       <arg value="-f"/>
140       <arg value="-c"/>
141       <arg value="-M"/>
142       <arg value="AndroidManifest.xml"/>
143       <arg value="-S"/>
144       <arg value="${resource-dir}"/>
145       <arg value="-A"/>
146       <arg value="${asset-dir}"/>
147       <arg value="-I"/>
148       <arg value="${android-jar}"/>
149       <arg value="${out-package}"/>
150     </exec>
151   </target>
152
153   <!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
154   <target name="package-res-no-assets">
155     <echo>Packaging resources...</echo>
156     <exec executable="${aapt}" failonerror="true">
157       <arg value="package"/>
158       <arg value="-f"/>
159       <arg value="-c"/>
160       <arg value="-M"/>
161       <arg value="AndroidManifest.xml"/>
162       <arg value="-S"/>
163       <arg value="${resource-dir}"/>
164       <!-- No assets directory -->
165       <arg value="-I"/>
166       <arg value="${android-jar}"/>
167       <arg value="${out-package}"/>
168     </exec>
169   </target>
170
171   <!-- Invoke the proper target depending on whether or not
172 an assets directory is present. -->
173   <!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
174 only when the assets dir exists. -->
175   <target name="package-res">
176     <available file="${asset-dir}" type="dir"
177                property="res-target" value="and-assets"/>
178     <property name="res-target" value="no-assets"/>
179     <antcall target="package-res-${res-target}"/>
180   </target>
181
182   <!-- Put the project's .class files into the output package file. -->
183   <target name="package-java" depends="compile, package-res">
184     <echo>Packaging java...</echo>
185     <jar destfile="${out-package}"
186          basedir="${outdir-classes}"
187          update="true"/>
188   </target>
189
190   <!-- Put the project's .dex files into the output package file. -->
191   <target name="package-dex" depends="dex, package-res">
192     <echo>Packaging dex...</echo>
193     <exec executable="${zip}" failonerror="true">
194       <arg value="-qj"/>
195       <arg value="${out-package}"/>
196       <arg value="${intermediate-dex}"/>
197     </exec>
198   </target>
199
200   <!-- Create the package file for this project from the sources. -->
201   <target name="package" depends="package-dex"/>
202 </project>