Ketan's Musings

Where he blogs about his eclipse musings

Run JRuby From Within A Jar And Package Your Own Gems Along

with 2 comments

Jruby-in a jar already bundles rspec and rake, so the goal was to find out where it gets packaged.

Download the jruby source zip, extract it and open the build.xml file, search for “rspec” (there’s two occurences) and you’ll find that it’s passed in as an argument to the gem installer, add in another line with “cucumber”:

<target name="install-gems">
  <property name="jruby.home" value="${basedir}"/>
  <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true">
    <classpath refid="build.classpath"/>
    <classpath path="${jruby.classes.dir}"/>
    <sysproperty key="jruby.home" value="${jruby.home}"/>
    <arg value="--command"/>
    <arg value="maybe_install_gems"/>
    <arg value="rspec"/>
    <arg value="rake"/>
    <arg value="cucumber"/> <!-- add cucumber -->
    <arg value="--env-shebang"/>
  </java>
</target>

Then run ant:

$ ant jar-complete

To verify that everything is fine:

$ java -jar lib/jruby-complete.jar -S gem list

*** LOCAL GEMS ***

builder (2.1.2)
cucumber (0.2.3)
diff-lcs (1.1.2)
polyglot (0.2.5)
rake (0.8.4)
rspec (1.2.2)
sources (0.0.1)
term-ansicolor (1.0.3)
treetop (1.2.5)

Great we’ve now managed to package jruby-in-a-jar with some additional gems. Now to run cucumber on jruby in eclipse.

Written by Ketan

April 10th, 2009 at 9:20 am

2 Responses to 'Run JRuby From Within A Jar And Package Your Own Gems Along'

Subscribe to comments with RSS or TrackBack to 'Run JRuby From Within A Jar And Package Your Own Gems Along'.

  1. This changed somewhat for jruby-1.5.0RC1, the version I was using when going through this procedure. The build.xml changed somewhat to where it is now.

    However, in the top level directory there is a default.build.properties file. In that I needed to add a line and modify another. I added:

    cucumber.gem=${build.lib.dir}/cucumber-0.6.4.gem

    and then modified:

    complete.jar.gems=${cucumber.gem} ${rspec.gem} ${rake.gem}….. and so on. The point here was to add ${cucumber.gem}.

    Next, there is no cucumber-0.6.4.gem file in the default build_lib directory so I had to create my own, which, I simply ran

    #gem build cucumber.gemspec

    against the gemspec file in the top level directory of the cucumber folder. Once complete I copied it to the build_lib directory in jruby.

    Voila. It built just fine. Now I’m off to add the plugin in eclipse.

    Reino Tanttila

    28 Apr 10 at 11:35 pm

  2. @Reino:

    Thanks for that input! I’ll update the blog post accordingly.

    Ketan

    29 Apr 10 at 9:22 pm

Leave a Reply

IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

What is 4 + 12 ?
Please leave these two fields as-is: