I think it looks pretty good as a first and one-off customization. One thing I would consider is to reuse the same JVM and call the autojar main() method directly instead of spawning a separate Java process for slightly faster builds. See http://buildr.apache.org/more_stuff.html#javaif you want to learn more.
alex On Sun, Aug 16, 2009 at 1:47 PM, Levin Alexander <[email protected]> wrote: > Hi, > > I'm looking to build stripped down jar files with only the minimally > needed dependencies included. I'm using autojar to do that. > > However I know next to nothing about buildr (or java packaging in > general) and would appreciate some review/critique of what I'm doing: > > def add_dependencies(pkg) > tempfile = pkg.to_s.sub(/.jar$/, "-without-dependencies.jar") > mv pkg.to_s, tempfile > > dependencies = compile.dependencies.map { |d| "-c #{d}"}.join(" ") > sh "java -jar tools/autojar.jar -baev -o #{pkg} #{dependencies} > #{tempfile}" > end > > # and in the project definition: > > package(:jar) > package(:jar).enhance { |pkg| pkg.enhance { |pkg| add_dependencies(pkg) > }} > > (also posted on stackoverflow.com here: > > http://stackoverflow.com/questions/1279419/buildr-package-dependencies-into-a-single-jar/1285293#1285293 > ) > > Is there a better way to do this? > > Thank You, > Levin >
