566ff8c6f926fa032a15e241fcc53c61bc486f9d
[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   <target name="init">
24     <tstamp/>
25   </target>
26
27   <target name="compile" depends="init">
28     <mkdir dir="build"/>
29     <javac srcdir="src"
30            destdir="build"
31            source="1.2"
32            target="1.2"
33            optimize="true"
34            debug="${generate-debug}"
35            deprecation="true"
36            fork="true"/>
37     <jar jarfile="core.jar" basedir="build">
38       <!-- These entries allow core.jar to function as an OSGi bundle, and also specifies
39            additional attributes for compatibility with BugLabs's BUG platform.
40            Thanks to David Albert for this change. -->
41       <manifest>
42         <attribute name="Bundle-Name" value="ZXing"/>
43         <attribute name="Bundle-Vendor" value="ZXing Project"/>
44         <attribute name="Bundle-SymbolicName" value="ZXing"/>
45         <attribute name="Bundle-Version" value="${version}"/>
46         <attribute name="Export-Package" value="com.google.zxing,com.google.zxing.common,com.google.zxing.client.result"/>
47         <attribute name="Bug-Bundle-Type" value="Application"/>
48       </manifest>
49     </jar>
50   </target>
51
52   <target name="build" depends="clean">
53     <antcall target="compile">
54       <param name="generate-debug" value="true"/>
55     </antcall>
56   </target>
57
58   <!-- This target is needed for building a core.jar which the Android client can use and run
59        ProGuard on successfully, because dx doesn't like debugging info. -->
60   <target name="build-no-debug" depends="clean">
61     <antcall target="compile">
62       <param name="generate-debug" value="false"/>
63     </antcall>
64   </target>
65
66   <!-- This target builds an optimized core.jar using ProGuard. It is not intended for our Android
67   client - use build-no-debug intead, then build the client which runs ProGuard on everything. -->
68   <target name="build-optimized" depends="clean">
69     <antcall target="compile">
70       <param name="generate-debug" value="false"/>
71     </antcall>
72
73     <delete file="core.jar"/>
74     <mkdir dir="optimized"/>
75     <java jar="${proguard-jar}" fork="true" failonerror="true">
76       <jvmarg value="-Dmaximum.inlined.code.length=48"/>
77       <arg value="-injars build"/>
78       <arg value="-outjars optimized"/>
79       <!-- Needed for Mac OS. -->
80       <!--<arg value="-libraryjars ${java.home}/../Classes/classes.jar"/>-->
81       <!-- Needed for other Android apps besides Barcode Scanner. -->
82       <!--<arg value="-libraryjars ${android-home}/platforms/android-1.6/android.jar"/>-->
83       <arg value="-keep class com.google.zxing.* {public protected *;}"/>
84       <arg value="-keep class com.google.zxing.common.*Binarizer {public protected *;}"/>
85       <!-- Remove this line is you only use the Result base object and want the smallest jar. -->
86       <arg value="-keep class com.google.zxing.client.result.* {public protected *;}"/>
87       <!-- Contains a useful UPC-E to UPC-A method. -->
88       <arg value="-keep class com.google.zxing.oned.UPCEReader {public *;}"/>
89       <arg value="-target 1.2"/>
90       <arg value="-optimizationpasses 4"/>
91       <arg value="-dontobfuscate"/>
92       <arg value="-dontskipnonpubliclibraryclasses"/>
93       <arg value="-verbose"/>
94     </java>
95     <jar jarfile="core.jar" basedir="optimized"/>
96   </target>
97
98   <target name="build-test" depends="init,build">
99     <fail message="Please build 'javase' first">
100       <condition>
101         <not>
102           <available file="../javase/javase.jar" type="file"/>
103         </not>
104       </condition>
105     </fail>
106     <mkdir dir="build-test"/>
107     <javac srcdir="test/src"
108            destdir="build-test"
109            debug="true"
110            deprecation="true">
111       <classpath>
112         <pathelement location="core.jar"/>
113         <pathelement location="../javase/javase.jar"/>
114         <pathelement location="lib/junit.jar"/>
115       </classpath>
116     </javac>
117   </target>
118
119   <target name="test-blackbox" depends="build-test">
120     <parallel failonany="true">
121       <antcall target="test-blackbox-subset">
122         <param name="subdir" value="datamatrix"/>
123       </antcall>
124       <antcall target="test-blackbox-subset">
125         <param name="subdir" value="negative"/>
126       </antcall>
127       <antcall target="test-blackbox-subset">
128         <param name="subdir" value="oned"/>
129       </antcall>
130       <antcall target="test-blackbox-subset">
131         <param name="subdir" value="pdf417"/>
132       </antcall>
133       <antcall target="test-blackbox-subset">
134         <param name="subdir" value="qrcode"/>
135       </antcall>
136     </parallel>
137   </target>
138
139   <target name="test-blackbox-subset">
140     <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
141       <formatter type="plain" usefile="false"/>
142       <classpath>
143         <pathelement location="core.jar"/>
144         <pathelement location="build-test"/>
145         <pathelement location="../javase/javase.jar"/>
146         <pathelement location="lib/junit.jar"/>
147       </classpath>
148       <assertions>
149         <enable/>
150       </assertions>
151       <batchtest>
152         <fileset dir="test/src">
153           <include name="**/${subdir}/*BlackBox*TestCase.java"/>
154           <exclude name="**/Abstract*.java"/>
155         </fileset>
156       </batchtest>
157     </junit>
158   </target>
159
160   <target name="test-unit" depends="build-test">
161     <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
162       <formatter type="plain" usefile="false"/>
163       <classpath>
164         <pathelement location="core.jar"/>
165         <pathelement location="build-test"/>
166         <pathelement location="../javase/javase.jar"/>
167         <pathelement location="lib/junit.jar"/>
168       </classpath>
169       <assertions>
170         <enable/>
171       </assertions>
172       <jvmarg value="-Xint"/> <!-- works around weird JIT bug in Java 6 -->
173       <batchtest>
174         <fileset dir="test/src">
175           <include name="**/*TestCase.java"/>
176           <exclude name="**/*BlackBox*TestCase.java"/>
177           <exclude name="**/Abstract*.java"/>
178         </fileset>
179       </batchtest>
180     </junit>
181   </target>
182
183   <target name="test" depends="test-unit,test-blackbox"/>
184
185   <target name="clean">
186     <delete dir="build"/>
187     <delete dir="build-test"/>
188     <delete dir="optimized"/>
189     <delete file="core.jar"/>
190     <delete file="ZXingReader.*"/>
191     <delete file="proguard-dump.txt"/>
192   </target>
193
194 </project>