Forum: JRuby Packaging Gems in a Jar File

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
0d1cd73bfe0ebe09074bfcd138ed3d5d?d=identicon&s=25 Keith B. (keith_b)
on 2013-07-15 22:50
(Received via mailing list)
Sorry, I'll add the subject line now. ;)

- Keith
Doug Hathaway (Guest)
on 2013-07-15 22:57
(Received via mailing list)
Have you looked into bundler <>?
This gem allows you to create a gemfile that lists all the dependent
"bundle install" will install all the required gems
You can also download and store these gems within the project locally
the "bundle package" command, in turn you can install those gems with
"bundle install --local" command.
Rhett Sutphin (Guest)
on 2013-07-15 22:58
(Received via mailing list)
Hi Keith,

I wrote an packaging extension for buildr which helps you bundle up a
collection of gems in a JAR in a way that JRuby can use them:

Even if you don't want to use the packager itself, the README describes
snags you might run into.


From:  Keith Bennett <>
Reply-To:  <>
Date:  Monday, July 15, 2013 3:46 PM
To:  <>
Subject:  [jruby-user] Packaging Gems in a Jar File

Sorry, I'll add the subject line now. ;)

- Keith

On Mon, Jul 15, 2013 at 4:45 PM, Keith Bennett <>
Colin Surprenant (Guest)
on 2013-07-15 23:41
(Received via mailing list)
Nice work Rhett! I also have done similar work in RedStorm to package gems into a
jar, but it is not a standalone process. My strategy was to use
Bundler for dependency resolution and copy the bundled gems into the
jar. I will take a look at your strategy and see if we can
iterate/improve with this.


On Mon, Jul 15, 2013 at 4:55 PM, Rhett Sutphin <>
> Rhett
> - Keith
>> Second best would be to ship the script itself, plus another file containing
>> of where the script is installed, and using that.
>> Thanks for any help.
>> - Keith

Rhett Sutphin (Guest)
on 2013-07-15 23:51
(Received via mailing list)
Hi Colin,

I think using bundler as part of the process is a great idea. I would
used it when I first wrote buildr-gemjar (in 2011), except I had a
requirement to be able to use locally-packaged .gem files. Bundler has
never directly supported this, but there is apparently a workaround you
can use now[1].

Anyway, I wrote up a bunch of notes about how I'd rework buildr-gemjar
use bundler[2], but I haven't had a chance to implement any of them yet.


R. Tyler Croy (Guest)
on 2013-07-16 01:47
(Received via mailing list)
On Mon, 15 Jul 2013, Keith Bennett wrote:

> >, but
> > it looks like it requires some coding, and I'm wondering if there's a yet
> > easier way to do it.
> >
> > What's the best way to do this these days?  If necessary, he may just fall
> > back to creating a custom gem home somewhere, maybe in a gems subdirectory
> > of where the script is installed, and using that.

Is using warbler not an option? I've been using warbler to create
jars for a while now and it works great.

I'm struggling to find the time to write up a good blog post on what
I've been
working on, but providing self-contained runnable jars has simplified a
for my team :)

- R. Tyler Croy
0d1cd73bfe0ebe09074bfcd138ed3d5d?d=identicon&s=25 Keith B. (keith_b)
on 2013-07-16 19:40
(Received via mailing list)
Guys -

Thanks for all your input.  It didn't occur to me to use warbler,
for some reason I thought it was specific to Rails.

We're aware of Bundler, and have been using it ourselves.  This use case
different though, as it involves distributing  software to a Java shop
little to no Ruby expertise, so they were hoping to reduce the entire
distribution to a single jar file.

However, I suspect that that might not be viable, because any gems we
package in the jar file will be built on a particular system.  Although
JRuby gems are in general written in JRuby, they can contain references
native code, right?  Or even contain native code?

Thanks again,
This topic is locked and can not be replied to.