Added androidtest to the top-level clean target and set it up for ProGuard too. Made...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Wed, 29 Oct 2008 20:13:05 +0000 (20:13 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Wed, 29 Oct 2008 20:13:05 +0000 (20:13 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@651 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/build.xml
androidtest/build.xml
build.xml

index b036492..701e0d9 100644 (file)
@@ -149,7 +149,7 @@ limitations under the License.
   </target>
 
   <!-- Compile this project's .java files into .class files. -->
-  <target name="compile" depends="dirs, resource-src, aidl">
+  <target name="compile" depends="clean, dirs, resource-src, aidl">
     <javac encoding="ascii" target="1.5" debug="true" extdirs=""
            srcdir="."
            destdir="${outdir-classes}"
@@ -160,7 +160,7 @@ limitations under the License.
     </javac>
   </target>
 
-  <target name="compile-release" depends="dirs, resource-src, aidl">
+  <target name="compile-release" depends="clean, dirs, resource-src, aidl">
     <javac encoding="ascii" target="1.5" debug="off" extdirs=""
            srcdir="."
            destdir="${outdir-classes}"
@@ -325,7 +325,7 @@ only when the assets dir exists. -->
   </target>
 
   <!-- Install the package on the default emulator -->
-  <target name="install" depends="debug">
+  <target name="install">
     <echo>Installing ${out-debug-package} onto default emulator...</echo>
     <exec executable="${adb}" failonerror="true">
       <arg value="install" />
@@ -333,7 +333,7 @@ only when the assets dir exists. -->
     </exec>
   </target>
 
-  <target name="reinstall" depends="debug">
+  <target name="reinstall">
     <echo>Installing ${out-debug-package} onto default emulator...</echo>
     <exec executable="${adb}" failonerror="true">
       <arg value="install" />
index 6c3f626..5761bc2 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" ?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
 Copyright (C) 2008 ZXing authors
 
@@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -->
-<project name="ZXingTest" default="debug">
+<project name="ZXingTest" default="debug-optimized">
   <!-- SDK Locations -->
   <property file="../build.properties"/>
   <property name="sdk-folder" value="${android-home}"/>
@@ -149,7 +149,7 @@ limitations under the License.
   </target>
 
   <!-- Compile this project's .java files into .class files. -->
-  <target name="compile" depends="dirs, resource-src, aidl">
+  <target name="compile" depends="clean, dirs, resource-src, aidl">
     <javac encoding="ascii" target="1.5" debug="true" extdirs=""
            srcdir="."
            destdir="${outdir-classes}"
@@ -160,6 +160,50 @@ limitations under the License.
     </javac>
   </target>
 
+  <target name="compile-release" depends="clean, dirs, resource-src, aidl">
+    <javac encoding="ascii" target="1.5" debug="off" extdirs=""
+           srcdir="."
+           destdir="${outdir-classes}"
+           bootclasspath="${android-jar}">
+      <classpath>
+        <fileset dir="${external-libs}" includes="*.jar"/>
+      </classpath>
+    </javac>
+  </target>
+
+  <target name="optimize" depends="compile-release">
+    <fail message="Please put proguard.jar in 'bin' under the WTK install directory">
+      <condition>
+        <not>
+          <available file="${WTK-home}/bin/proguard.jar" type="file"/>
+        </not>
+      </condition>
+    </fail>
+    <unzip src="../core/core.jar" dest="${outdir-classes}" overwrite="true"/>
+    <jar jarfile="temp.jar" basedir="${outdir-classes}"/>
+    <delete dir="${outdir-classes}"/>
+    <mkdir dir="${outdir-classes}"/>
+    <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 temp-optimized.jar"/>
+      <arg value="-libraryjars ${android-jar}"/>
+      <arg value="-keepattributes Exceptions,InnerClasses,Signature,!LocalVariableTable,!LocalVariableTypeTable"/>
+      <arg value="-keep class com.google.zxing.client.android.*Activity"/>
+      <arg value="-target 5"/>
+      <arg value="-optimizationpasses 7"/>
+      <arg value="-allowaccessmodification"/>
+      <arg value="-dontshrink"/>
+      <arg value="-dontobfuscate"/>
+      <arg value="-dontskipnonpubliclibraryclasses"/>
+      <arg value="-verbose"/>
+      <arg value="-dump proguard-dump.txt"/>
+    </java>
+    <delete file="temp.jar"/>
+    <unzip src="temp-optimized.jar" dest="${outdir-classes}" overwrite="true"/>
+    <delete file="temp-optimized.jar"/>
+  </target>
+
   <!-- Convert this project's .class files into .dex files. -->
   <target name="dex" depends="compile">
     <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
@@ -171,6 +215,17 @@ limitations under the License.
     </apply>
   </target>
 
+  <target name="dex-optimized" depends="compile-release,optimize">
+    <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
+    <apply executable="${dx}" failonerror="true" parallel="true">
+      <arg value="--dex" />
+      <arg value="--output=${intermediate-dex-ospath}" />
+      <arg path="${outdir-classes-ospath}" />
+      <!-- workaround to appease 'apply'. Not really the right Ant task to use here. -->
+      <fileset dir="." includes="nosuchfile.jar"/>
+    </apply>
+  </target>
+
   <!-- Put the project's resources into the output package file. -->
   <target name="package-res-and-assets">
     <echo>Packaging resources and assets...</echo>
@@ -236,9 +291,25 @@ only when the assets dir exists. -->
     </exec>
   </target>
 
+  <!-- Package the optimized application and sign it with a debug key. -->
+  <target name="debug-optimized" depends="dex-optimized, package-res">
+    <echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
+    <exec executable="${apk-builder}" failonerror="true">
+      <arg value="${out-debug-package-ospath}" />
+      <arg value="-z" />
+      <arg value="${resources-package-ospath}" />
+      <arg value="-f" />
+      <arg value="${intermediate-dex-ospath}" />
+      <arg value="-rf" />
+      <arg value="${srcdir-ospath}" />
+      <arg value="-rj" />
+      <arg value="${external-libs-ospath}" />
+    </exec>
+  </target>
+
   <!-- Package the application without signing it.
         This allows for the application to be signed later with an official publishing key. -->
-  <target name="release" depends="dex, package-res">
+  <target name="release" depends="dex-optimized, package-res">
     <echo>Packaging ${out-unsigned-package} for release...</echo>
     <exec executable="${apk-builder}" failonerror="true">
       <arg value="${out-unsigned-package-ospath}" />
@@ -249,14 +320,12 @@ only when the assets dir exists. -->
       <arg value="${intermediate-dex-ospath}" />
       <arg value="-rf" />
       <arg value="${srcdir-ospath}" />
-      <arg value="-rj" />
-      <arg value="${external-libs-ospath}" />
     </exec>
     <echo>It will need to be signed with jarsigner before being published.</echo>
   </target>
 
   <!-- Install the package on the default emulator -->
-  <target name="install" depends="debug">
+  <target name="install">
     <echo>Installing ${out-debug-package} onto default emulator...</echo>
     <exec executable="${adb}" failonerror="true">
       <arg value="install" />
@@ -264,7 +333,7 @@ only when the assets dir exists. -->
     </exec>
   </target>
 
-  <target name="reinstall" depends="debug">
+  <target name="reinstall">
     <echo>Installing ${out-debug-package} onto default emulator...</echo>
     <exec executable="${adb}" failonerror="true">
       <arg value="install" />
@@ -284,6 +353,7 @@ only when the assets dir exists. -->
 
   <target name="clean">
     <delete dir="${outdir}"/>
+    <delete file="proguard-dump.txt"/>
   </target>
 
 </project>
index b043524..80ea1c6 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -41,6 +41,7 @@
     <ant dir="javase" target="clean"/>
     <ant dir="bug" target="clean"/>    
     <ant dir="android" target="clean"/>
+    <ant dir="androidtest" target="clean"/>
     <ant dir="rim" target="clean"/>
     <ant dir="zxingorg" target="clean"/>
     <delete dir="docs/javadoc"/>