Renamed core OSGi bundle to "ZXing"; removed "level=" attribute on <jar> tasks since...
[zxing.git] / core / build.xml
index 970f70b..ef39f63 100644 (file)
@@ -23,7 +23,6 @@
   <path id="javame-compile-bootclasspath">
     <fileset dir="${WTK-home}/lib">
       <include name="cldcapi11.jar"/>
-      <include name="midpapi20.jar"/>
     </fileset>
   </path>
   <property name="javame-compile-bootclasspath-path" refid="javame-compile-bootclasspath"/>
            debug="true"
            deprecation="true"
            fork="true"/>
-    <jar jarfile="core.jar" basedir="build" level="9"/>
+    <jar jarfile="core.jar" basedir="build">
+      <!-- These entries allow core.jar to function as an OSGi bundle, and also specifices
+           additional attributes for compatibility with BugLabs's BUG platform.
+           Thanks to David Albert for this change. -->
+      <manifest>
+        <attribute name="Bundle-Name" value="ZXing"/>
+        <attribute name="Bundle-Vendor" value="ZXing Project"/>
+        <attribute name="Bundle-SymbolicName" value="ZXing"/>
+        <attribute name="Bundle-Version" value="${version}"/>        
+        <attribute name="Export-Package" value="com.google.zxing,com.google.zxing.common,com.google.zxing.client.result"/>
+        <attribute name="Bug-Bundle-Type" value="Application"/>
+      </manifest>
+    </jar>
   </target>
 
-  <target name="test" depends="init,build">
+  <target name="build-optimized" depends="build">
+    <move file="core.jar" tofile="temp.jar"/>
+    <java jar="${WTK-home}/bin/proguard.jar" fork="true" failonerror="true">
+      <jvmarg value="-Dmaximum.inlined.code.length=32"/>
+      <arg value="-injars temp.jar"/>
+      <arg value="-outjars core.jar"/>
+      <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
+      <arg value="-renamesourcefileattribute SourceFile"/>
+      <arg value="-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod"/>
+      <arg value="-keep public class com.google.zxing.* { public protected *; }"/>
+      <arg value="-keep public class com.google.zxing.client.result.* { public protected *; }"/>
+      <arg value="-keep public class com.google.zxing.common.* { public protected *; }"/>
+      <arg value="-optimizationpasses 7"/>
+      <arg value="-overloadaggressively"/>
+      <arg value="-allowaccessmodification"/>
+      <arg value="-verbose"/>
+    </java>
+    <delete file="temp.jar"/>
+  </target>
+
+  <target name="build-test" depends="init,build">
+    <fail message="Please build 'javase' first">
+      <condition>
+        <not>
+          <available file="../javase/javase.jar" type="file"/>
+        </not>
+      </condition>
+    </fail>
     <mkdir dir="build-test"/>
     <javac srcdir="test/src"
            destdir="build-test"
            debug="true"
            deprecation="true">
       <classpath>
-        <pathelement location="build"/>
+        <pathelement location="core.jar"/>
         <pathelement location="../javase/javase.jar"/>
+        <pathelement location="lib/junit.jar"/>
       </classpath>
     </javac>
-    <junit printsummary="on" haltonfailure="on" haltonerror="on">
+  </target>
+
+  <target name="test-blackbox" depends="build-test">
+    <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
       <formatter type="plain" usefile="false"/>
       <classpath>
-        <pathelement location="build"/>
+        <pathelement location="core.jar"/>
         <pathelement location="build-test"/>
-        <pathelement location="../javase/javase.jar"/>        
+        <pathelement location="../javase/javase.jar"/>
+        <pathelement location="lib/junit.jar"/>
       </classpath>
       <assertions>
         <enable/>
       </assertions>
       <batchtest>
         <fileset dir="test/src">
-          <include name="**/*.java"/>
+          <include name="**/*BlackBox*TestCase.java"/>
+          <exclude name="com/google/zxing/common/AbstractBlackBoxTestCase.java"/>
         </fileset>
       </batchtest>
     </junit>
   </target>
 
+  <target name="test-unit" depends="build-test">
+    <junit printsummary="on" haltonfailure="on" haltonerror="on" fork="true" dir=".">
+      <formatter type="plain" usefile="false"/>
+      <classpath>
+        <pathelement location="core.jar"/>
+        <pathelement location="build-test"/>
+        <pathelement location="../javase/javase.jar"/>
+        <pathelement location="lib/junit.jar"/>
+      </classpath>
+      <assertions>
+        <enable/>
+      </assertions>
+      <batchtest>
+        <fileset dir="test/src">
+          <exclude name="**/*BlackBox*TestCase.java"/>
+        </fileset>
+      </batchtest>
+    </junit>
+  </target>
+
+  <target name="test" depends="test-unit,test-blackbox"/>
+
   <target name="clean">
     <delete dir="build"/>
     <delete dir="build-test"/>