Checks that dependencies are built now and produces an appropriate warning message.
[zxing.git] / javame / build.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4  Copyright 2007 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 <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   </target>
82
83   <target name="compile-basic" depends="init">
84     <mkdir dir="build"/>
85     <!-- For an explanation of this odd build command, see javadoc in
86          src/com/google/zxing/client/j2me/AdvancedMultimediaManager.java -->
87     <javac srcdir="src-basic"
88            destdir="build"
89            source="1.2"
90            target="1.2"
91            bootclasspath="${javame-compile-bootclasspath-path}"
92            optimize="true"
93            debug="true"
94            deprecation="true"
95            fork="true">
96        <classpath refid="wtk-build-path"/>
97     </javac>
98     <javac srcdir="src"
99            destdir="build"
100            source="1.2"
101            target="1.2"
102            bootclasspath="${javame-compile-bootclasspath-path}"
103            optimize="true"
104            debug="true"
105            deprecation="true"
106            fork="true">
107       <classpath refid="wtk-build-path"/>
108       <exclude name="com/google/zxing/client/j2me/AdvancedMultimediaManager.java"/>
109     </javac>
110   </target>
111
112   <target name="package">
113     <unzip src="../core/core.jar" dest="build"/>
114
115     <mkdir dir="build-j2me"/>
116     <exec executable="${WTK-home}/bin/preverify1.1">
117       <arg line="-classpath ${preverify-classpath} -d build-j2me build"/>
118     </exec>
119
120     <copy todir="build-j2me">
121       <fileset dir=".">
122         <include name="res/**"/>
123       </fileset>
124     </copy>
125
126     <copy file="src/com/google/zxing/client/j2me/MANIFEST.MF.template" tofile="src/com/google/zxing/client/j2me/MANIFEST.MF" overwrite="true">
127       <filterset>
128         <filter token="APP_NAME" value="${jar-name}"/>
129         <filter token="VERSION" value="${version}"/>
130       </filterset>
131     </copy>
132
133     <jar jarfile="${jar-name}.jar" basedir="build-j2me" manifest="src/com/google/zxing/client/j2me/MANIFEST.MF" level="9"/>
134
135     <move file="${jar-name}.jar" tofile="temp.jar"/>
136     <java jar="${WTK-home}/bin/proguard.jar" fork="true">
137       <arg value="-injars temp.jar"/>
138       <arg value="-outjars ${jar-name}.jar"/>
139       <arg value="-libraryjars ${preverify-classpath}"/>
140       <arg value="-microedition"/>
141       <arg value="-keep public class com.google.zxing.client.j2me.ZXingMIDlet"/>
142       <arg value="-keep public class com.google.zxing.qrcode.detector.DefaultGridSampler"/>
143       <arg value="-keep public class com.google.zxing.qrcode.detector.GridSampler"/>
144       <arg value="-optimizationpasses 5"/>
145       <arg value="-verbose"/>
146     </java>
147     <delete file="temp.jar"/>
148
149     <!-- get .jar size to include it in the .jad file -->
150     <length file="${jar-name}.jar" property="jar-size"/>
151
152     <copy file="ZXingReader.jad.template" tofile="${jar-name}.jad" overwrite="true">
153       <filterset>
154         <filter token="JAR_SIZE" value="${jar-size}"/>
155         <filter token="APP_NAME" value="${jar-name}"/>
156         <filter token="VERSION" value="${version}"/>
157       </filterset>
158     </copy>
159
160   </target>
161
162   <target name="build">
163     <description>Builds the main reader .jar file</description>
164     <property name="jar-name" value="ZXingReader"/>
165     <antcall target="clean"/>
166     <antcall target="compile"/>
167     <antcall target="package"/>
168   </target>
169
170   <target name="build-basic">
171     <description>Builds the basic reader .jar file</description>
172     <property name="jar-name" value="ZXingReaderBasic"/>
173     <antcall target="clean"/>
174     <antcall target="compile-basic"/>
175     <antcall target="package"/>
176   </target>
177
178   <target name="clean">
179     <delete dir="build"/>
180     <delete dir="build-j2me"/>
181     <delete dir="." includes="*.jar"/>
182     <delete dir="." includes="*.jad"/>
183     <delete file="src/com/google/zxing/client/j2me/MANIFEST.MF"/>
184   </target>
185
186 </project>