views:

337

answers:

1

I'd like to build a java applet with all its dependencies included, but still keeping the jar as small as possible. I'm using buildr.

It looks like autojar is the tool I'm looking for.

Now I need to integrate the two. This is what I have:

package.enhance do |p|
  p.enhance do |pkg|
    tempfile = pkg.to_s.sub(/.jar$/, "-unstripped.jar")
    classes = ["example/foo/Class.class", "example/bar/Other.class"]
    mv pkg.to_s, tempfile
    sh "java -jar autojar.jar -bae -o #{pkg} -c #{tempfile} #{classes.join(' ')}"
  end
end

this sort of works, but is kludgy and works around buildr instead of integrating with it (I'm losing the generated manifest and all the other things explicitly packaged in the jar that buildr has generated)

Ideally I'd like to be able to write something like:

package(:jar, :minify => true, :include => ["example/foo/Class.foo"])
# or maybe this:
package(:autojar, :include => ["example/foo/Class.foo"])

Is there some existing plugin for buildr that does this? If not: How can I integrate autojar into buildr?

A: 

see this answer for a solution that works for me.

levinalex