Dealing with JRuby and jars

Luis Lavena luislavena at
Mon Jan 9 15:07:53 EST 2012

On Mon, Jan 9, 2012 at 3:59 PM, Charles Oliver Nutter
<headius at> wrote:
> Ok, we need to figure out a solution here :)

Let's see,

Bear with me my naive answers...

> Here's the deal:
> JRuby users are using JVM libraries. That's obviously a big selling
> point of JRuby. They're also living in the Ruby world, and use
> RubyGems, Bundler, etc. They don't want to have to manage dependencies
> multiple ways.
> Ruby world revolves around RubyGems and Bundler. Java world revolves
> around Maven. We want to integrate the two for JRuby users in a way
> that RubyGems,, and Bundler folks can accept.
> JRuby currently supports installing jars from Maven at the "gem"
> command line, but that's the only place it works. does
> not allow us to push gems with maven dependencies, and Bundler does
> not recognize maven dependencies.

What about a extension to Gem::Installer provided by JRuby that uses
Gem::Specification metadata field?
(of Course, RubyGems master at this time)

> What we need:
> * A way for RubyGems to understand Maven artifacts and dependency
> graphs and fetch them. We have that at the command line, but it's via
> our own patches.

Gem::Installer provides pre and post install hooks.

You can't use rubygems/defaults/#{RUBY_ENGINE}.rb ?

> * A way for to allow gems that have Maven dependencies.
> The alternatives to this are pushing gems that *just* wrap a jar file
> (some of them very large) or hosting a JRuby-specific I
> don't like either of those options.

I vote for metadata usage.

> * A way for Bundler to recognize Maven dependencies as though they are gems.

Dunno how Bundler installer gems, so can't comment. I was guess it
uses Gem::Installer and didn't reinvent the wheel.
(Isolate at least uses it)

> I'm looking for thoughts and suggestions on how we can make this
> easier. It's one of the biggest headaches for JRuby users right now,
> since they have to use multiple mechanisms to track dependencies. I
> also don't want to flood with a bunch of giant jar-only
> gems when we can simply source them from Maven mirrors.
> So...what do you think?

On a different project I've started to work on a plugin that uses this
metadata information to install missing binaries, similar to what you
want to accomplish for JRuby.

Since metadata is not available yet, what if you use spec.requirements array?

Something like: do |s|
  s.requirements = [

$ gem spec --local pkg/testext-0.0.1.gem

- maven:junit.junit-4.10

That would work?

Luis Lavena
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

More information about the RubyGems-Developers mailing list