If this doesn't make you weep tears of joy, then you have no heart:
http://gist.github.com/271764
Thanks to Tamas Cservenak from Sonatype, we will soon have a special
gem server that presents all the world's Java libraries as installable
Ruby Gems!
The format of the gem name is basically using the maven group and
artifact IDs plus the version number. So for this version of Rhino,
the group ID is 'rhino' and the artifact ID is also 'rhino', so the
gem name becomes "rhino.rhino-1.5.4.1-java" (and the -java part just
indicates this is a gem for jruby).
The resulting gem that installs is basically just a wrapper for the
jar file. Here's the structure of the rhino gem:
~/projects/jruby/lib/ruby/gems/1.8/gems ➔ ls -1 -R rhino.rhino-1.5.4.1-java/
lib
rhino.rhino-1.5.4.1-java//lib:
rhino-1.5R4.1.jar
rhino.rhino.rb
It's really barebones. The rhino.rhino.rb file is generated as well,
and basically just loads the jar for you:
~/projects/jruby/lib/ruby/gems/1.8/gems ➔ cat
rhino.rhino-1.5.4.1-java/lib/rhino.rhino.rb
module Rhino
VERSION = '1.5.4.1'
MAVEN_VERSION = '1.5R4.1'
end
begin
require 'java'
require File.dirname(__FILE__) + '/rhino-1.5R4.1.jar'
rescue LoadError
puts 'JAR-based gems require JRuby to load. Please visit www.jruby.org.'
raise
end
So I have a few questions and thoughts about how to use this newfound power:
* I would like to add the Maven/Gem proxy server to the default list
of gem sources for JRuby 1.5
* You will soon be able to specify these libraries as dependencies in
regular gems, since RubyGems will just use the combination of
gemcutter + sonatype to resolve everything.
* Does the structure of the rhino.rhino.rb file look reasonable?
* Should we also provide some utility methods on the Rhino module for
just retrieving the jar file path?
* Should we require the user to require the jar? I ask because it may
make bundling jar-based gems into an app if we can see what jar files
are physically being loaded.
I'd love to hear any other thoughts you have. I'm really excited about this :)
- Charlie
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email