Warbler

From JRubyWiki

Jump to: navigation, search

http://caldersphere.rubyforge.org/warbler/

Warbler is a gem to make a .war file out of a Rails project. The intent is to provide a minimal, flexible, ruby-like way to bundle up all of your application files for deployment to a Java application server.

Warbler provides a sane set of out-of-the box defaults that should allow most Rails applications without external gem dependencies (aside from Rails itself) to assemble and Just Work.

Warbler bundles JRuby and the Goldspike servlet for dispatching requests to your application inside the java application server, and assembles all jar files in WARBLER_HOME/lib/*.jar into your application. No external dependencies are downloaded.

Created by Nick Sieger Announcement: Warbler, A Little Birdie To Introduce Your Rails App To Java (Nick Sieger)

Defaults

  • Currently, the Warbler gem includes JRuby 1.0.1 (will not work with Rails 2.0) - this can be overridden after install. For example, to use 1.0.3 instead do the following:
    1. Download jruby-complete-1.0.3.jar
    2. Copy jruby-complete-1.0.3.jar into Warbler's lib directory:
      $ cp jruby-complete-1.0.3.jar <ruby-home>/gems/1.8/gems/warbler-0.9.1/lib/jruby-complete-1.0.3.jar
    3. Remove jruby-complete-1.0.1.jar:
      rm <ruby-home>/gems/1.8/gems/warbler-0.9.1/lib/jruby-complete-1.0.1.jar
  • It is also possible to set different versions of JRuby and GoldSpike without modifying the gem files. This ensures that your build is reproducible.
    1. Modify <rails_app>/config/warbler.rb, and add the following line:
      config.java_libs.reject! {|lib| lib =~ /jruby-complete|goldspike/ }
    2. Copy jruby-complete-1.0.3.jar and goldspike-1.3.jar to <rails_app>/lib.
  • For a pre-release version of Warbler that will work with Rails 2.0, simply
    gem install warbler --source http://caldersphere.net
    . It includes JRuby 1.0.3 and Goldspike 1.4. The current version available via regular gem install warbler includes JRuby 1.1 RC2.

Automatically figure out gems

The following code snippet in config/warbler.rb will cause Warbler to automatically bundle all gems loaded by the web application.

  # Include all gems which are used by the web application
  require "#{RAILS_ROOT}/config/boot"
  BUILD_GEMS = %w(warbler rake rcov)
  for gem in Gem.loaded_specs.values
    next if BUILD_GEMS.include?(gem.name)
    config.gems[gem.name] = gem.version.version
  end

See Also

Personal tools