Walter Rumsby
Walter Rumsby

Reputation: 7535

jRuby called in Ant can't find gems, what am I doing wrong

I have the following in an Ant target:

<java jar="tools/jars/jruby-complete.jar" fork="true">
    <arg value="-r"/>
    <arg value="tools/jars/chunky_png.jar"/>
    <arg value="-r"/>
    <arg value="tools/jars/compass.jar"/>
    <arg value="-S"/>
    <arg value="compass/compass-compile.rb"/>
    <arg value="${basedir}"/>
</java>

Assume the paths are correct (I've changed them slightly for this example).

My build is failing because the Gems can't be found with an error message:

`report_activate_error': Could not find RubyGem chunky_png (~> 0.12.0) (Gem::LoadError)

If I install the Gems via gem this will work, but I don't want to do that because I can't guarantee what will be on the build server.

Upvotes: 1

Views: 1259

Answers (2)

Walter Rumsby
Walter Rumsby

Reputation: 7535

Problem ended up being that I had created my chunky_png.jar incorrectly.

Having a look at Gems in a Jar I noticed that my .jar should contain a specifications directory, which my .jar didn't.

Fixing up how I created the .jar resolved the issue.

Upvotes: 2

Simon Lieschke
Simon Lieschke

Reputation: 13324

The command line parameter documentation for JRuby doesn't have spaces between the -r flag and the library. Does the following work?

<java jar="tools/jars/jruby-complete.jar" fork="true">
    <arg value="-rtools/jars/chunky_png.jar"/>
    <arg value="-rtools/jars/compass.jar"/>
    <arg value="-S"/>
    <arg value="compass/compass-compile.rb"/>
    <arg value="${basedir}"/>
</java>

Another thing to try would be putting the archives containing your gems on the classpath for your java task.

Upvotes: 0

Related Questions