minifying the launcher for 2.8

14 views
Skip to first unread message

Mark Harrah

unread,
Jun 15, 2010, 5:38:17 PM6/15/10
to simple-b...@googlegroups.com
As expected, the size of the launcher jar shot up after compiling it with 2.8
(an additional 300-400kB or so).

Since it might be useful to others using ProGuard with Scala, here is what I
did to get back the 300kB. It isn't really 2.8 specific- it is just some more
aggressive settings that I used to compensate for the increase in size from
2.8.

ProGuard removes annotations in the obfuscation step. I don't want my
classes/members to be renamed, but I do want to remove annotations and most
attributes, including the Scala signature annotation.

I previously completely disabled obfuscation:
-dontobfuscate

Instead, I now use:
-keep,allowoptimization,allowshrinking class * { *; }",
-keepattributes SourceFile,LineNumberTable

This prevents renaming but still strips attributes/annotations. If you need
to preserve certain annotations, you can append them to -keepattributes.

I also needed to enable optimization to reduce it another 100kB. I dropped -
dontoptimize and added:
-optimizationpasses 2
-optimizations !code/allocation/variable

More passes increase processing time, but you might get a larger size decrease
or a performance increase. Three passes did not reduce the size any more than
two did for me. The second line disables an optimization that did not work
for me (it gave a runtime error).

-Mark

Viktor Klang

unread,
Jun 15, 2010, 5:42:05 PM6/15/10
to simple-b...@googlegroups.com
Thanks for the tips and tricks!


--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.




--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang

Brian Clapper

unread,
Jun 15, 2010, 9:49:46 PM6/15/10
to simple-b...@googlegroups.com
On 06/15/2010 05:38 PM, Mark Harrah wrote:
> As expected, the size of the launcher jar shot up after compiling it with 2.8
> (an additional 300-400kB or so).

[snip]

This info is highly useful. Since I'm also writing some command-line Scala
programs, I can easily see myself using this information very soon.

Mark, any chance you might consider throwing it up on the SBT wiki? I know
it's not SBT-specific, but the wiki seems like a reasonable place for now.

If not, I'll just bookmark this thread. ;-)

Thanks for writing this up.
--
-Brian

Brian Clapper, http://www.clapper.org/bmc/
I am astounded ... at the wonderful power you have developed -- and terrified
at the thought that so much hideous and bad music may be put on record
forever.
-- Arthur Sullivan, on seeing a demonstration of Edison's new
talking machine in 1888

Mark Harrah

unread,
Jun 18, 2010, 3:40:02 PM6/18/10
to simple-b...@googlegroups.com
On Tuesday, June 15, 2010 09:49:46 pm Brian Clapper wrote:
> On 06/15/2010 05:38 PM, Mark Harrah wrote:
> > As expected, the size of the launcher jar shot up after compiling it with
> > 2.8 (an additional 300-400kB or so).
>
> [snip]
>
> This info is highly useful. Since I'm also writing some command-line Scala
> programs, I can easily see myself using this information very soon.
>
> Mark, any chance you might consider throwing it up on the SBT wiki? I know
> it's not SBT-specific, but the wiki seems like a reasonable place for now.

Sure. This is only one part of configuring ProGuard with Scala of course.

http://code.google.com/p/simple-build-tool/wiki/ProGuard

-Mark

Reply all
Reply to author
Forward
0 new messages