Neat! I added this to our How-To section. http://cwiki.apache.org/confluence/display/BUILDR/How+to+include+dependencies+in+.jar+packages
Thanks for sharing. alex On Fri, Nov 27, 2009 at 4:31 AM, Levin Alexander <levin.alexan...@gmail.com>wrote: > On Fri, Nov 27, 2009 at 9:44 AM, tommycli <tommy...@ucla.edu> wrote: > > > > I use buildr with the transitive compile.with artifact specifications. > > > > My problem is this: After buildr makes its package, I have a nice JAR > file, > > but I cannot run it without its dependency JARs. > > > > I don't even know which JARs it depends on. How do you find out which > JARs > > you need to distribute with your project? Can buildr package all of it > into > > one file? > > I am using autojar with builder to find and bundle dependencies to the Jar: > > 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 > > package(:jar).enhance { |pkg| pkg.enhance { |pkg| add_dependencies(pkg) }} > > < > http://stackoverflow.com/questions/1279419/buildr-package-dependencies-into-a-single-jar/1285293#1285293 > > > > this is a hack and potentially has problems (it uses autojar's > dependency resolution mechanism and therefore cannot find dynamically > added dependencies) but for us it works quite well in practice. > > -Levin >