Fixed the double delete problem remaining in issue 503.
[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       <!-- These are used with WTK 2.5.x -->
26       <!--
27       <include name="cldcapi11.jar"/>
28       <include name="midpapi20.jar"/>
29       <include name="mmapi.jar"/>
30       <include name="jsr234.jar"/>
31       <include name="satsa-apdu.jar"/>
32       -->
33       <include name="cldc_1.1.jar"/>
34       <include name="midp_2.0.jar"/>
35       <include name="jsr135_1.2.jar"/>
36       <include name="jsr234_1.0.jar"/>
37     </fileset>
38     <pathelement location="../core/core.jar"/>
39   </path>
40   <property name="preverify-classpath" refid="wtk-build-path"/>
41
42   <path id="javame-compile-bootclasspath">
43     <fileset dir="${WTK-home}/lib">
44       <!-- These are used with WTK 2.5.x -->
45       <!--
46       <include name="cldcapi11.jar"/>
47       <include name="midpapi20.jar"/>
48       -->
49       <include name="cldc_1.1.jar"/>
50       <include name="midp_2.0.jar"/>
51     </fileset>
52   </path>
53   <property name="javame-compile-bootclasspath-path" refid="javame-compile-bootclasspath"/>
54
55   <target name="init">
56     <tstamp/>
57     <fail message="Please set 'WTK-home' in build.properties">
58       <condition>
59         <not>
60           <available file="${WTK-home}" type="dir"/>
61         </not>
62       </condition>
63     </fail>
64     <fail message="Please set 'proguard.jar' in build.properties">
65       <condition>
66         <not>
67           <available file="${proguard-jar}" type="file"/>
68         </not>
69       </condition>
70     </fail>
71     <fail message="Please build 'core' first">
72       <condition>
73         <not>
74           <available file="../core/core.jar" type="file"/>
75         </not>
76       </condition>
77     </fail>
78   </target>
79
80   <target name="build" depends="init">
81     <mkdir dir="build"/>
82     <javac srcdir="src"
83            destdir="build"
84            source="1.2"
85            target="1.2"
86            bootclasspath="${javame-compile-bootclasspath-path}"
87            optimize="true"
88            debug="true"
89            deprecation="true"
90            fork="true">
91       <classpath refid="wtk-build-path"/>
92     </javac>
93     <jar jarfile="javame.jar" basedir="build"/>
94
95     <unzip src="../core/core.jar" dest="build"/>
96
97     <!--
98     <mkdir dir="build-j2me"/>
99     <exec executable="${WTK-home}/bin/preverify1.1" failonerror="true">
100       <arg line="-classpath '${preverify-classpath}' -d build-j2me build"/>
101     </exec>
102     -->
103     <copy todir="build-j2me">
104       <fileset dir="build"/>
105     </copy>
106
107     <copy todir="build-j2me">
108       <fileset dir=".">
109         <include name="res/**"/>
110       </fileset>
111     </copy>
112
113     <copy file="src/com/google/zxing/client/j2me/MANIFEST.MF.template"
114           tofile="src/com/google/zxing/client/j2me/MANIFEST.MF" overwrite="true">
115       <filterset>
116         <filter token="APP_NAME" value="BarcodeReader"/>
117         <filter token="VERSION" value="${version}"/>
118       </filterset>
119     </copy>
120
121     <jar jarfile="BarcodeReader.jar" basedir="build-j2me" manifest="src/com/google/zxing/client/j2me/MANIFEST.MF"/>
122
123     <move file="BarcodeReader.jar" tofile="temp.jar"/>
124     <java jar="${proguard-jar}" fork="true" failonerror="true">
125       <jvmarg value="-Dmaximum.inlined.code.length=32"/>
126       <arg value="-injars temp.jar"/>
127       <arg value="-outjars BarcodeReader.jar"/>
128       <!-- These are used with WTK 2.5.x -->
129       <!--
130       <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
131       <arg value="-libraryjars ${WTK-home}/lib/midpapi20.jar"/>
132       <arg value="-libraryjars ${WTK-home}/lib/mmapi.jar"/>
133       <arg value="-libraryjars ${WTK-home}/lib/jsr234.jar"/>
134       -->
135       <arg value="-libraryjars ${WTK-home}/lib/cldc_1.1.jar"/>
136       <arg value="-libraryjars ${WTK-home}/lib/midp_2.0.jar"/>
137       <arg value="-libraryjars ${WTK-home}/lib/jsr135_1.2.jar"/>
138       <arg value="-libraryjars ${WTK-home}/lib/jsr234_1.0.jar"/>
139       <arg value="-microedition"/>
140       <arg value="-keep public class com.google.zxing.client.j2me.ZXingMIDlet"/>
141       <arg value="-keep class com.google.zxing.client.j2me.AdvancedMultimediaManager"/>
142       <arg value="-keep class com.google.zxing.client.j2me.DefaultMultimediaManager"/>
143       <arg value="-keep class com.google.zxing.client.j2me.MultimediaManager"/>      
144       <arg value="-optimizationpasses 5"/>
145       <arg value="-overloadaggressively"/>
146       <arg value="-allowaccessmodification"/>
147       <arg value="-verbose"/>
148       <arg value="-dump proguard-dump.txt"/>
149     </java>
150     <delete file="temp.jar"/>
151
152     <!-- get .jar size to include it in the .jad file -->
153     <length file="BarcodeReader.jar" property="jar-size"/>
154
155     <copy file="BarcodeReader.jad.template" tofile="BarcodeReader.jad" overwrite="true">
156       <filterset>
157         <filter token="JAR_SIZE" value="${jar-size}"/>
158         <filter token="APP_NAME" value="BarcodeReader"/>
159         <filter token="VERSION" value="${version}"/>
160       </filterset>
161     </copy>
162
163   </target>
164
165   <target name="dump">
166     <java jar="${proguard-jar}" fork="true">
167       <arg value="-injars BarcodeReader.jar"/>
168       <!-- These are used with WTK 2.5.x -->
169       <!--
170       <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
171       <arg value="-libraryjars ${WTK-home}/lib/midpapi20.jar"/>
172       <arg value="-libraryjars ${WTK-home}/lib/mmapi.jar"/>
173       <arg value="-libraryjars ${WTK-home}/lib/jsr234.jar"/>
174       -->
175       <arg value="-libraryjars ${WTK-home}/lib/cldc_1.1.jar"/>
176       <arg value="-libraryjars ${WTK-home}/lib/midp_2.0.jar"/>
177       <arg value="-libraryjars ${WTK-home}/lib/jsr135_1.2.jar"/>
178       <arg value="-libraryjars ${WTK-home}/lib/jsr234_1.0.jar"/>
179       <arg value="-dontshrink"/>
180       <arg value="-dontobfuscate"/>
181       <arg value="-dontoptimize"/>
182       <arg value="-dump dump.txt"/>
183     </java>
184   </target>
185
186   <target name="clean">
187     <delete dir="build"/>
188     <delete dir="build-j2me"/>
189     <delete dir="." includes="*.jar"/>
190     <delete dir="." includes="*.jad"/>
191     <delete file="src/com/google/zxing/client/j2me/MANIFEST.MF"/>
192     <delete file="proguard-dump.txt"/>
193   </target>
194
195 </project>