Remove level="9" here (oops) and add a dump target for debugging
[zxing.git] / javame / build.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4  Copyright 2007 ZXing authors
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 <project name="javame" default="build">
20
21   <property file="../build.properties"/>
22
23   <path id="wtk-build-path">
24     <fileset dir="${WTK-home}/lib">
25       <include name="cldcapi11.jar"/>
26       <include name="midpapi20.jar"/>
27       <include name="mmapi.jar"/>
28       <include name="jsr234.jar"/>
29       <include name="satsa-apdu.jar"/>
30     </fileset>
31     <pathelement location="../core/core.jar"/>
32   </path>
33   <property name="preverify-classpath" refid="wtk-build-path"/>
34
35   <path id="javame-compile-bootclasspath">
36     <fileset dir="${WTK-home}/lib">
37       <include name="cldcapi11.jar"/>
38       <include name="midpapi20.jar"/>
39     </fileset>
40   </path>
41   <property name="javame-compile-bootclasspath-path" refid="javame-compile-bootclasspath"/>
42
43   <target name="init">
44     <tstamp/>
45     <fail message="Please set 'WTK-home' in build.properties">
46       <condition>
47         <not>
48           <available file="${WTK-home}" type="dir"/>
49         </not>
50       </condition>
51     </fail>
52     <fail message="Please put proguard.jar in 'bin' under the WTK install directory">
53       <condition>
54         <not>
55           <available file="${WTK-home}/bin/proguard.jar" type="file"/>
56         </not>
57       </condition>
58     </fail>
59     <fail message="Please build 'core' first">
60       <condition>
61         <not>
62           <available file="../core/core.jar" type="file"/>
63         </not>
64       </condition>
65     </fail>
66   </target>
67
68   <target name="compile" depends="init">
69     <mkdir dir="build"/>
70     <javac srcdir="src"
71            destdir="build"
72            source="1.2"
73            target="1.2"
74            bootclasspath="${javame-compile-bootclasspath-path}"
75            optimize="true"
76            debug="true"
77            deprecation="true"
78            fork="true">
79       <classpath refid="wtk-build-path"/>
80     </javac>
81     <jar jarfile="javame.jar" basedir="build"/>
82   </target>
83
84   <target name="compile-basic" depends="init">
85     <mkdir dir="build"/>
86     <!-- For an explanation of this odd build command, see javadoc in
87          src/com/google/zxing/client/j2me/AdvancedMultimediaManager.java -->
88     <javac srcdir="src-basic"
89            destdir="build"
90            source="1.2"
91            target="1.2"
92            bootclasspath="${javame-compile-bootclasspath-path}"
93            optimize="true"
94            debug="true"
95            deprecation="true"
96            fork="true">
97       <classpath refid="wtk-build-path"/>
98     </javac>
99     <javac srcdir="src"
100            destdir="build"
101            source="1.2"
102            target="1.2"
103            bootclasspath="${javame-compile-bootclasspath-path}"
104            optimize="true"
105            debug="true"
106            deprecation="true"
107            fork="true">
108       <classpath refid="wtk-build-path"/>
109       <exclude name="com/google/zxing/client/j2me/AdvancedMultimediaManager.java"/>
110     </javac>
111     <jar jarfile="javame-basic.jar" basedir="build"/>
112   </target>
113
114   <target name="package">
115     <unzip src="../core/core.jar" dest="build"/>
116
117     <mkdir dir="build-j2me"/>
118     <exec executable="${WTK-home}/bin/preverify1.1" failonerror="true">
119       <arg line="-classpath '${preverify-classpath}' -d build-j2me build"/>
120     </exec>
121
122     <copy todir="build-j2me">
123       <fileset dir=".">
124         <include name="res/**"/>
125       </fileset>
126     </copy>
127
128     <copy file="src/com/google/zxing/client/j2me/MANIFEST.MF.template"
129           tofile="src/com/google/zxing/client/j2me/MANIFEST.MF" overwrite="true">
130       <filterset>
131         <filter token="APP_NAME" value="${jar-name}"/>
132         <filter token="VERSION" value="${version}"/>
133       </filterset>
134     </copy>
135
136     <jar jarfile="${jar-name}.jar" basedir="build-j2me" manifest="src/com/google/zxing/client/j2me/MANIFEST.MF"/>
137
138     <move file="${jar-name}.jar" tofile="temp.jar"/>
139     <java jar="${WTK-home}/bin/proguard.jar" fork="true" failonerror="true">
140       <jvmarg value="-Dmaximum.inlined.code.length=32"/>
141       <arg value="-injars temp.jar"/>
142       <arg value="-outjars ${jar-name}.jar"/>
143       <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
144       <arg value="-libraryjars ${WTK-home}/lib/midpapi20.jar"/>
145       <arg value="-libraryjars ${WTK-home}/lib/mmapi.jar"/>
146       <arg value="-libraryjars ${WTK-home}/lib/jsr234.jar"/>
147       <arg value="-microedition"/>
148       <arg value="-keep public class com.google.zxing.client.j2me.ZXingMIDlet"/>
149       <arg value="-optimizationpasses 7"/>
150       <arg value="-overloadaggressively"/>
151       <arg value="-allowaccessmodification"/>
152       <arg value="-verbose"/>
153     </java>
154     <delete file="temp.jar"/>
155
156     <!-- get .jar size to include it in the .jad file -->
157     <length file="${jar-name}.jar" property="jar-size"/>
158
159     <copy file="BarcodeReader.jad.template" tofile="${jar-name}.jad" overwrite="true">
160       <filterset>
161         <filter token="JAR_SIZE" value="${jar-size}"/>
162         <filter token="APP_NAME" value="${jar-name}"/>
163         <filter token="VERSION" value="${version}"/>
164       </filterset>
165     </copy>
166
167   </target>
168
169   <target name="build">
170     <description>Builds the main reader .jar file</description>
171     <property name="jar-name" value="BarcodeReader"/>
172     <antcall target="clean"/>
173     <antcall target="compile"/>
174     <antcall target="package"/>
175   </target>
176
177   <target name="build-basic">
178     <description>Builds the basic reader .jar file</description>
179     <property name="jar-name" value="BarcodeReaderBasic"/>
180     <antcall target="clean"/>
181     <antcall target="compile-basic"/>
182     <antcall target="package"/>
183   </target>
184
185   <target name="dump">
186     <java jar="${WTK-home}/bin/proguard.jar" fork="true">
187       <arg value="-injars BarcodeReader.jar"/>
188       <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
189       <arg value="-libraryjars ${WTK-home}/lib/midpapi20.jar"/>
190       <arg value="-libraryjars ${WTK-home}/lib/mmapi.jar"/>
191       <arg value="-libraryjars ${WTK-home}/lib/jsr234.jar"/>
192       <arg value="-dontshrink"/>
193       <arg value="-dontobfuscate"/>
194       <arg value="-dontoptimize"/>
195       <arg value="-dump dump.txt"/>
196     </java>
197   </target>
198
199   <target name="clean">
200     <delete dir="build"/>
201     <delete dir="build-j2me"/>
202     <delete dir="." includes="*.jar"/>
203     <delete dir="." includes="*.jad"/>
204     <delete file="src/com/google/zxing/client/j2me/MANIFEST.MF"/>
205   </target>
206
207 </project>