moved ProGuard optimization into Android build file since it's the only way to fully...
[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       <arg value="-dump proguard-dump.txt"/>        
91     </java>
92     <delete file="temp.jar"/>
93   </target>
94
95   <target name="build-test" depends="init,build">
96     <fail message="Please build 'javase' first">
97       <condition>
98         <not>
99           <available file="../javase/javase.jar" type="file"/>
100         </not>
101       </condition>
102     </fail>
103     <mkdir dir="build-test"/>
104     <javac srcdir="test/src"
105            destdir="build-test"
106            debug="true"
107            deprecation="true">
108       <classpath>
109         <pathelement location="core.jar"/>
110         <pathelement location="../javase/javase.jar"/>
111         <pathelement location="lib/junit.jar"/>
112       </classpath>
113     </javac>
114   </target>
115
116   <target name="test-blackbox" depends="build-test">
117     <parallel failonany="true">
118       <antcall target="test-blackbox-subset">
119         <param name="subdir" value="datamatrix"/>
120       </antcall>
121       <antcall target="test-blackbox-subset">
122         <param name="subdir" value="negative"/>
123       </antcall>
124       <antcall target="test-blackbox-subset">
125         <param name="subdir" value="oned"/>
126       </antcall>
127       <antcall target="test-blackbox-subset">
128         <param name="subdir" value="qrcode"/>
129       </antcall>
130     </parallel>
131   </target>
132
133   <target name="test-blackbox-subset">
134     <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
135       <formatter type="plain" usefile="false"/>
136       <classpath>
137         <pathelement location="core.jar"/>
138         <pathelement location="build-test"/>
139         <pathelement location="../javase/javase.jar"/>
140         <pathelement location="lib/junit.jar"/>
141       </classpath>
142       <assertions>
143         <enable/>
144       </assertions>
145       <batchtest>
146         <fileset dir="test/src">
147           <include name="**/${subdir}/*BlackBox*TestCase.java"/>
148         </fileset>
149       </batchtest>
150     </junit>
151   </target>
152
153   <target name="test-unit" depends="build-test">
154     <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
155       <formatter type="plain" usefile="false"/>
156       <classpath>
157         <pathelement location="core.jar"/>
158         <pathelement location="build-test"/>
159         <pathelement location="../javase/javase.jar"/>
160         <pathelement location="lib/junit.jar"/>
161       </classpath>
162       <assertions>
163         <enable/>
164       </assertions>
165       <batchtest>
166         <fileset dir="test/src">
167           <include name="**/*TestCase.java"/>          
168           <exclude name="**/*BlackBox*TestCase.java"/>
169         </fileset>
170       </batchtest>
171     </junit>
172   </target>
173
174   <target name="test" depends="test-unit,test-blackbox"/>
175
176   <target name="clean">
177     <delete dir="build"/>
178     <delete dir="build-test"/>
179     <delete file="core.jar"/>
180     <delete file="ZXingReader.*"/>
181     <delete file="proguard-dump.txt"/>
182   </target>
183
184 </project>