2008/10/27 Stuart McCulloch <[EMAIL PROTECTED]>

> based on a quick hack of the Guice codebase to switch to reduced
> versions of Maps, Lists, etc. (as the number of statics used is small)
> we could shrink the jar to at least 600k, ie. a saving of 30%
>
> hmm, I might take a peek at hacking JarJar to do this :)
>

FYI, I tried switching to use proguard but I couldn't find a way to make
proguard rename the packages but keep the original class names :(

but you can use it to strip unused static methods and then use jarjar
to rename the packages (see patch below) - though it would be cool
if we could get jarjar to do all of this...

the final guice jar after proguard'ing and jarjar'ing is ~600k

-- 
Cheers, Stuart


Index: build.xml
===================================================================
--- build.xml   (revision 649)
+++ build.xml   (working copy)
@@ -11,15 +11,30 @@

   <target name="jar" depends="compile, manifest"
        description="Build jar.">
+    <taskdef resource="proguard/ant/task.properties"
+      classpath="lib/build/proguard.jar"/>
     <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
       classpath="lib/build/jarjar-1.0rc8.jar"/>
     <mkdir dir="${build.dir}/dist"/>
+    <proguard>
+      -libraryjars ${java.home}/lib/rt.jar
+      -libraryjars ${ant.home}/lib/ant.jar
+      -libraryjars lib/aopalliance.jar
+      -injars ${build.dir}/classes
+      -injars lib/build/cglib-2.2.jar(!META-INF/**)
+      -injars lib/build/asm-3.1.jar(!META-INF/**)
+      -injars lib/build/google-collect-snapshot-20080530.jar(!META-INF/**)
+      -outjars ${build.dir}/stripped.jar
+      -keep class com.google.inject.** { *; }
+      -keepclassmembers class !com.google.common.** { *; }
+      -keepattributes
+      -dontobfuscate
+      -dontoptimize
+      -dontnote
+    </proguard>
     <jarjar jarfile="${build.dir}/dist/guice-${version}.jar"
         manifest="${build.dir}/META-INF/MANIFEST.MF">
-      <fileset dir="${build.dir}/classes"/>
-      <zipfileset src="lib/build/cglib-2.2.jar"/>
-      <zipfileset src="lib/build/asm-3.1.jar"/>
-      <zipfileset src="lib/build/google-collect-snapshot-20080530.jar"/>
+      <zipfileset src="${build.dir}/stripped.jar"/>
       <rule pattern="com.google.common.**"
result="[EMAIL PROTECTED]"/>
       <rule pattern="net.sf.cglib.**"
result="[EMAIL PROTECTED]"/>
       <rule pattern="org.objectweb.asm.**"
result="[EMAIL PROTECTED]"/>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to