More fixes to the build files after trying to build the whole thing again for release
[zxing.git] / core / build.xml
index b890d90..192b4a7 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
- Copyright 2007 Google Inc.
+ Copyright 2007 ZXing authors
 
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@
     <tstamp/>
   </target>
 
-  <target name="build" depends="init">
+  <target name="compile" depends="init">
     <mkdir dir="build"/>
     <javac srcdir="src"
            destdir="build"
            target="1.2"
            bootclasspath="${javame-compile-bootclasspath-path}"
            optimize="true"
-           debug="true"
+           debug="${generate-debug}"
            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="build" depends="clean">
+    <antcall target="compile">
+      <param name="generate-debug" value="true"/>
+    </antcall>
+  </target>
+
+  <target name="build-no-debug" depends="clean">
+    <antcall target="compile">
+      <param name="generate-debug" value="false"/>
+    </antcall>
   </target>
 
-  <target name="build-optimized" depends="build">
+  <!-- This target really supports the Android client, where we can't as easily build
+       an optimized .apk directly, and need an optimized library. We have to strip debug info
+       above to appease dex -->
+  <target name="build-optimized" depends="build-no-debug">
     <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="-keepattributes Exceptions,InnerClasses,Signature,!LocalVariableTable,!LocalVariableTypeTable"/>
       <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="-dontshrink"/>
+      <arg value="-dontobfuscate"/>
       <arg value="-optimizationpasses 7"/>
-      <arg value="-overloadaggressively"/>
-      <arg value="-allowaccessmodification"/>
       <arg value="-verbose"/>
     </java>
     <delete file="temp.jar"/>
   </target>
 
+  <target name="dump">
+    <java jar="${WTK-home}/bin/proguard.jar" fork="true">
+      <arg value="-injars core.jar"/>
+      <arg value="-libraryjars ${WTK-home}/lib/cldcapi11.jar"/>
+      <arg value="-dontshrink"/>
+      <arg value="-dontobfuscate"/>
+      <arg value="-dontoptimize"/>
+      <arg value="-dump dump.txt"/>
+    </java>
+  </target>
+
   <target name="build-test" depends="init,build">
     <fail message="Please build 'javase' first">
       <condition>
         <fileset dir="test/src">
           <include name="**/*BlackBox*TestCase.java"/>
           <exclude name="com/google/zxing/common/AbstractBlackBoxTestCase.java"/>
+          <exclude name="com/google/zxing/common/AbstractNegativeBlackBoxTestCase.java"/>
         </fileset>
       </batchtest>
     </junit>
     <delete dir="build"/>
     <delete dir="build-test"/>
     <delete file="core.jar"/>
+    <delete file="ZXingReader.*"/>
   </target>
 
 </project>