Monday, June 1, 2009

How to Get Warbler to Include a Custom Version of JRuby and JRuby-rack

If you want to use your own jruby-complete and jruby-rack jars in your project, here's how to do it, thanks to Nick Sieger for example of how to change the rack version.

In warble.rb, change this section so it looks like this:

  # Additional Java .jar files to include. Note that if .jar files are placed
  # in lib (and not otherwise excluded) then they need not be mentioned here.
  # JRuby and JRuby-Rack are pre-loaded in this list. Be sure to include your
  # own versions if you directly set the value
  # config.java_libs += FileList["lib/java/*.jar"]
  config.java_libs.delete_if {|f| f =~ /jruby-rack/ || f =~ /jruby-complete/ }
  config.java_libs += FileList["lib/jruby-complete*.jar"]
  config.java_libs += FileList["lib/jruby-rack*.jar"]

That will let you put your own version of jruby rack and jruby complete into your lib/ dir.

Then get and build jruby via git clone git:// You'll need Ant 1.7+ (I used 1.7.1) and Git. Then run "ant jar-complete" and copy jruby-complete.jar from the lib directory under the checked-out jruby. Use the jruby-rack jar you want also, for example "(jruby version)/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-rack-0.9.4.jar", or you could check it out and built it as well if you wanted.

Note that you will want to blow away your tmp/war dir, any existing war, as well undeploy the webapp, etc. to clean up after making any changes to jars, or you might continue to include the old ones. Note that the first two of those items can be done via:

warble war:clean

Don't forget that if you are using that version of jruby in the app, you'll want to use it in tests also. Make sure your JRUBY_HOME env var is pointed to a symlink that is pointed to the jruby dir from git. And make sure your PATH includes $JRUBY_HOME/bin.

1 comment:

Gary S. Weaver said...

This fix also helped Arun Gupta with JRUBY_RACK-18. Arun also blogged about it. Thanks again to Nick Sieger!