Add proguard optimizer support. Switch to compile against WTK class files and target...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 29 Nov 2007 19:44:05 +0000 (19:44 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 29 Nov 2007 19:44:05 +0000 (19:44 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@84 59b500cc-1b3d-0410-9834-0bbf25fbcc57

build.properties
core/build.xml
javame/build.xml

index c037d7d..9c86d0f 100644 (file)
@@ -8,23 +8,8 @@ version=0.1.2
 WTK-home=/usr/local/WTK2.5.2
 #WTK-home=C:\\WTK2.5.2
 
-# Set this to a location where the platform classes included with Java version 1.4 (not later)
-# have been installed. If you installed a full JDK, this is typically at 'jre/lib/rt.jar'
-# under the JDK installation directory. If you just installed a JRE, it is typically at
-# 'lib/rt.jar' under the JRE installation directory.
-#
-# Windows users: typically Java will be installed in a subdirectory of C:\Program Files\Java
-#
-# Linux users: installation directory varies, but is typically under /usr/local or /usr/lib
-#
-# Mac users, the Java 1.4 classes are at:
-# /System/Library/Frameworks/JavaVM.framework/Versions/1.4/Classes/classes.jar
-JDK1.4-classes=/usr/lib/jvm/j2sdk1.4.2_16/jre/lib/rt.jar
-#JDK1.4-classes=C:\\Program Files\\Java\\j2re1.4.2_16\\lib\\rt.jar
-#JDK1.4-classes=/System/Library/Frameworks/JavaVM.framework/Versions/1.4/Classes/classes.jar
-
 # Set this to the location where you have installed RIM's BlackBerry JDE in order to
 # create the 'rim' client. There is no Mac or Linux version, but, these platforms can still
 # build by obtaining a copy of net_rim_api.jar and rapc.jar from a Windows installation,
 # and simply pointing to the directory containing them both here:
-BB-JDK-home=.
\ No newline at end of file
+BB-JDK-home=.
index 9cac6f4..0f60ca3 100644 (file)
 
   <property file="../build.properties"/>
 
+  <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"/>
+
   <target name="init">
     <tstamp/>
-    <fail message="Please set 'JDK1.4-classes' in build.properties">
-      <condition>
-        <not>
-          <available file="${JDK1.4-classes}" type="file"/>
-        </not>
-      </condition>
-    </fail>
   </target>
 
   <target name="build" depends="init">
     <mkdir dir="build"/>
     <javac srcdir="src"
            destdir="build"
-           source="1.4"
-           target="1.4"
-           bootclasspath="${JDK1.4-classes}"
+           source="1.2"
+           target="1.2"
+           bootclasspath="${javame-compile-bootclasspath-path}"
            optimize="true"
            debug="true"
            deprecation="true"
@@ -59,7 +60,7 @@
       <formatter type="plain" usefile="false"/>
       <classpath>
         <pathelement location="build"/>
-        <pathelement location="build-test"/>        
+        <pathelement location="build-test"/>
       </classpath>
       <assertions>
         <enable/>
@@ -74,7 +75,7 @@
 
   <target name="clean">
     <delete dir="build"/>
-    <delete dir="build-test"/>    
+    <delete dir="build-test"/>
     <delete file="core.jar"/>
   </target>
 
index d181f3d..2292e41 100644 (file)
     </fileset>
     <pathelement location="../core/core.jar"/>
   </path>
+  <property name="preverify-classpath" refid="wtk-build-path"/>
+
+  <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"/>
 
   <target name="init">
     <tstamp/>
-    <fail message="Please set 'JDK1.4-classes' in build.properties">
+    <fail message="Please set 'WTK-home' in build.properties">
       <condition>
         <not>
-          <available file="${JDK1.4-classes}" type="file"/>
+          <available file="${WTK-home}" type="dir"/>
         </not>
       </condition>
     </fail>
-    <fail message="Please set 'WTK-home' in build.properties">
+    <fail message="Please put proguard.jar in 'bin' under the WTK install directory">
       <condition>
         <not>
-          <available file="${WTK-home}" type="dir"/>
+          <available file="${WTK-home}/bin/proguard.jar" type="file"/>
         </not>
       </condition>
     </fail>
@@ -53,9 +62,9 @@
     <mkdir dir="build"/>
     <javac srcdir="src"
            destdir="build"
-           source="1.4"
-           target="1.4"
-           bootclasspath="${JDK1.4-classes}"
+           source="1.2"
+           target="1.2"
+           bootclasspath="${javame-compile-bootclasspath-path}"
            optimize="true"
            debug="true"
            deprecation="true"
@@ -70,9 +79,9 @@
          src/com/google/zxing/client/j2me/AdvancedMultimediaManager.java -->
     <javac srcdir="src-basic"
            destdir="build"
-           source="1.4"
-           target="1.4"
-           bootclasspath="${JDK1.4-classes}"
+           source="1.2"
+           target="1.2"
+           bootclasspath="${javame-compile-bootclasspath-path}"
            optimize="true"
            debug="true"
            deprecation="true"
@@ -81,9 +90,9 @@
     </javac>
     <javac srcdir="src"
            destdir="build"
-           source="1.4"
-           target="1.4"
-           bootclasspath="${JDK1.4-classes}"
+           source="1.2"
+           target="1.2"
+           bootclasspath="${javame-compile-bootclasspath-path}"
            optimize="true"
            debug="true"
            deprecation="true"
     <unzip src="../core/core.jar" dest="build"/>
 
     <mkdir dir="build-j2me"/>
-    <property name="preverify-classpath" refid="wtk-build-path"/>
     <exec executable="${WTK-home}/bin/preverify1.1">
       <arg line="-classpath ${preverify-classpath} -d build-j2me build"/>
     </exec>
     <copy file="src/com/google/zxing/client/j2me/MANIFEST.MF.template" tofile="src/com/google/zxing/client/j2me/MANIFEST.MF" overwrite="true">
       <filterset>
         <filter token="APP_NAME" value="${jar-name}"/>
-        <filter token="VERSION" value="${version}"/>        
+        <filter token="VERSION" value="${version}"/>
       </filterset>
     </copy>
 
     <jar jarfile="${jar-name}.jar" basedir="build-j2me" manifest="src/com/google/zxing/client/j2me/MANIFEST.MF" level="9"/>
 
+    <move file="${jar-name}.jar" tofile="temp.jar"/>
+    <java jar="${WTK-home}/bin/proguard.jar" fork="true">
+      <arg value="-injars temp.jar"/>
+      <arg value="-outjars ${jar-name}.jar"/>
+      <arg value="-libraryjars ${preverify-classpath}"/>
+      <arg value="-microedition"/>
+      <arg value="-keep public class com.google.zxing.client.j2me.ZXingMIDlet"/>
+      <arg value="-keep public class com.google.zxing.qrcode.deteor.DefaultGridSampler"/>
+      <arg value="-keep public class com.google.zxing.qrcode.detector.GridSampler"/>
+      <arg value="-optimizationpasses 5"/>
+      <arg value="-verbose"/>
+    </java>
+    <delete file="temp.jar"/>
+
     <!-- get .jar size to include it in the .jad file -->
     <length file="${jar-name}.jar" property="jar-size"/>