Add support for core.jar as OSGi bundle, component in BugLabs's BUG platform
[zxing.git] / core / 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="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="build" 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="true"
43            deprecation="true"
44            fork="true"/>
45     <jar jarfile="core.jar" basedir="build" level="9">
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="ZXing4Bug"/>
51         <attribute name="Bundle-Vendor" value="ZXing Project"/>
52         <attribute name="Bundle-SymbolicName" value="ZXing4Bug"/>
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-optimized" depends="build">
61     <move file="core.jar" tofile="temp.jar"/>
62     <java jar="${WTK-home}/bin/proguard.jar" fork="true" failonerror="true">
63       <jvmarg value="-Dmaximum.inlined.code.length=32"/>
64       <arg value="-injars temp.jar"/>
65       <arg value="-outjars core.jar"/>
66       <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
67       <arg value="-renamesourcefileattribute SourceFile"/>
68       <arg value="-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod"/>
69       <arg value="-keep public class com.google.zxing.* { public protected *; }"/>
70       <arg value="-keep public class com.google.zxing.client.result.* { public protected *; }"/>
71       <arg value="-keep public class com.google.zxing.common.* { public protected *; }"/>
72       <arg value="-optimizationpasses 7"/>
73       <arg value="-overloadaggressively"/>
74       <arg value="-allowaccessmodification"/>
75       <arg value="-verbose"/>
76     </java>
77     <delete file="temp.jar"/>
78   </target>
79
80   <target name="build-test" depends="init,build">
81     <fail message="Please build 'javase' first">
82       <condition>
83         <not>
84           <available file="../javase/javase.jar" type="file"/>
85         </not>
86       </condition>
87     </fail>
88     <mkdir dir="build-test"/>
89     <javac srcdir="test/src"
90            destdir="build-test"
91            debug="true"
92            deprecation="true">
93       <classpath>
94         <pathelement location="core.jar"/>
95         <pathelement location="../javase/javase.jar"/>
96         <pathelement location="lib/junit.jar"/>
97       </classpath>
98     </javac>
99   </target>
100
101   <target name="test-blackbox" depends="build-test">
102     <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
103       <formatter type="plain" usefile="false"/>
104       <classpath>
105         <pathelement location="core.jar"/>
106         <pathelement location="build-test"/>
107         <pathelement location="../javase/javase.jar"/>
108         <pathelement location="lib/junit.jar"/>
109       </classpath>
110       <assertions>
111         <enable/>
112       </assertions>
113       <batchtest>
114         <fileset dir="test/src">
115           <include name="**/*BlackBox*TestCase.java"/>
116           <exclude name="com/google/zxing/common/AbstractBlackBoxTestCase.java"/>
117         </fileset>
118       </batchtest>
119     </junit>
120   </target>
121
122   <target name="test-unit" depends="build-test">
123     <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
124       <formatter type="plain" usefile="false"/>
125       <classpath>
126         <pathelement location="core.jar"/>
127         <pathelement location="build-test"/>
128         <pathelement location="../javase/javase.jar"/>
129         <pathelement location="lib/junit.jar"/>
130       </classpath>
131       <assertions>
132         <enable/>
133       </assertions>
134       <batchtest>
135         <fileset dir="test/src">
136           <exclude name="**/*BlackBox*TestCase.java"/>
137         </fileset>
138       </batchtest>
139     </junit>
140   </target>
141
142   <target name="test" depends="test-unit,test-blackbox"/>
143
144   <target name="clean">
145     <delete dir="build"/>
146     <delete dir="build-test"/>
147     <delete file="core.jar"/>
148   </target>
149
150 </project>