More fixes to the build files after trying to build the whole thing again for release
[zxing.git] / core / 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="core" default="build">
20
21   <property file="../build.properties"/>
22
23   <path id="javame-compile-bootclasspath">
24     <fileset dir="${WTK-home}/lib">
25       <include name="cldcapi11.jar"/>
26     </fileset>
27   </path>
28   <property name="javame-compile-bootclasspath-path" refid="javame-compile-bootclasspath"/>
29
30   <target name="init">
31     <tstamp/>
32   </target>
33
34   <target name="compile" depends="init">
35     <mkdir dir="build"/>
36     <javac srcdir="src"
37            destdir="build"
38            source="1.2"
39            target="1.2"
40            bootclasspath="${javame-compile-bootclasspath-path}"
41            optimize="true"
42            debug="${generate-debug}"
43            deprecation="true"
44            fork="true"/>
45     <jar jarfile="core.jar" basedir="build">
46       <!-- These entries allow core.jar to function as an OSGi bundle, and also specifices
47            additional attributes for compatibility with BugLabs's BUG platform.
48            Thanks to David Albert for this change. -->
49       <manifest>
50         <attribute name="Bundle-Name" value="ZXing"/>
51         <attribute name="Bundle-Vendor" value="ZXing Project"/>
52         <attribute name="Bundle-SymbolicName" value="ZXing"/>
53         <attribute name="Bundle-Version" value="${version}"/>        
54         <attribute name="Export-Package" value="com.google.zxing,com.google.zxing.common,com.google.zxing.client.result"/>
55         <attribute name="Bug-Bundle-Type" value="Application"/>
56       </manifest>
57     </jar>
58   </target>
59
60   <target name="build" depends="clean">
61     <antcall target="compile">
62       <param name="generate-debug" value="true"/>
63     </antcall>
64   </target>
65
66   <target name="build-no-debug" depends="clean">
67     <antcall target="compile">
68       <param name="generate-debug" value="false"/>
69     </antcall>
70   </target>
71
72   <!-- This target really supports the Android client, where we can't as easily build
73        an optimized .apk directly, and need an optimized library. We have to strip debug info
74        above to appease dex -->
75   <target name="build-optimized" depends="build-no-debug">
76     <move file="core.jar" tofile="temp.jar"/>
77     <java jar="${WTK-home}/bin/proguard.jar" fork="true" failonerror="true">
78       <jvmarg value="-Dmaximum.inlined.code.length=32"/>
79       <arg value="-injars temp.jar"/>
80       <arg value="-outjars core.jar"/>
81       <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
82       <arg value="-keepattributes Exceptions,InnerClasses,Signature,!LocalVariableTable,!LocalVariableTypeTable"/>
83       <arg value="-keep public class com.google.zxing.* { public protected *; }"/>
84       <arg value="-keep public class com.google.zxing.client.result.* { public protected *; }"/>
85       <arg value="-keep public class com.google.zxing.common.* { public protected *; }"/>
86       <arg value="-dontshrink"/>
87       <arg value="-dontobfuscate"/>
88       <arg value="-optimizationpasses 7"/>
89       <arg value="-verbose"/>
90     </java>
91     <delete file="temp.jar"/>
92   </target>
93
94   <target name="dump">
95     <java jar="${WTK-home}/bin/proguard.jar" fork="true">
96       <arg value="-injars core.jar"/>
97       <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
98       <arg value="-dontshrink"/>
99       <arg value="-dontobfuscate"/>
100       <arg value="-dontoptimize"/>
101       <arg value="-dump dump.txt"/>
102     </java>
103   </target>
104
105   <target name="build-test" depends="init,build">
106     <fail message="Please build 'javase' first">
107       <condition>
108         <not>
109           <available file="../javase/javase.jar" type="file"/>
110         </not>
111       </condition>
112     </fail>
113     <mkdir dir="build-test"/>
114     <javac srcdir="test/src"
115            destdir="build-test"
116            debug="true"
117            deprecation="true">
118       <classpath>
119         <pathelement location="core.jar"/>
120         <pathelement location="../javase/javase.jar"/>
121         <pathelement location="lib/junit.jar"/>
122       </classpath>
123     </javac>
124   </target>
125
126   <target name="test-blackbox" depends="build-test">
127     <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
128       <formatter type="plain" usefile="false"/>
129       <classpath>
130         <pathelement location="core.jar"/>
131         <pathelement location="build-test"/>
132         <pathelement location="../javase/javase.jar"/>
133         <pathelement location="lib/junit.jar"/>
134       </classpath>
135       <assertions>
136         <enable/>
137       </assertions>
138       <batchtest>
139         <fileset dir="test/src">
140           <include name="**/*BlackBox*TestCase.java"/>
141           <exclude name="com/google/zxing/common/AbstractBlackBoxTestCase.java"/>
142           <exclude name="com/google/zxing/common/AbstractNegativeBlackBoxTestCase.java"/>
143         </fileset>
144       </batchtest>
145     </junit>
146   </target>
147
148   <target name="test-unit" depends="build-test">
149     <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
150       <formatter type="plain" usefile="false"/>
151       <classpath>
152         <pathelement location="core.jar"/>
153         <pathelement location="build-test"/>
154         <pathelement location="../javase/javase.jar"/>
155         <pathelement location="lib/junit.jar"/>
156       </classpath>
157       <assertions>
158         <enable/>
159       </assertions>
160       <batchtest>
161         <fileset dir="test/src">
162           <exclude name="**/*BlackBox*TestCase.java"/>
163         </fileset>
164       </batchtest>
165     </junit>
166   </target>
167
168   <target name="test" depends="test-unit,test-blackbox"/>
169
170   <target name="clean">
171     <delete dir="build"/>
172     <delete dir="build-test"/>
173     <delete file="core.jar"/>
174     <delete file="ZXingReader.*"/>
175   </target>
176
177 </project>