Last updated July 07, 2009 05:40, by Paul
Feedicon  

Warbler

Warbler is a gem that makes a .war file out of a Rails, Merb, or Rack-based application. The intent is to provide a minimal, flexible, ruby-like way to bundle all 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 JRuby-Rack servlet adapter 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.

Getting Started

  1. Install the gem: gem install warbler.
  2. Run Warbler in the top directory of your Rails application: warble.
  3. Deploy your railsapp.war file to your favorite Java application server.

Usage

Warbler's warble command is just a small wrapper around Rake with internally defined tasks.

Note: Although rake prints out in the messages below, you must substitute warble for rake on the command line.

 $ warble -T
 rake config         # Generate a configuration file to customize your war assembly
 rake pluginize      # Unpack warbler as a plugin in your Rails application
 rake war            # Create trunk.war
 rake war:app        # Copy all application files into the .war
 rake war:clean      # Clean up the .war file and the staging area
 rake war:gems       # Unpack all gems into WEB-INF/gems
 rake war:jar        # Run the jar command to create the .war
 rake war:java_libs  # Copy all java libraries into the .war
 rake war:public     # Copy all public HTML files to the root of the .war
 rake war:webxml     # Generate a web.xml file for the webapp

Warbler makes heavy use of Rake's file and directory tasks, so only recently updated files will be copied, making repeated assemblies much faster.

Configuration

Rails applications

Rails applications are detected automatically and configured appropriately. The following items are set up for you:

Merb Applications

Merb applications are detected automatically, and the merb-core gem and its dependencies are packaged.

Other Rack-based Applications

If you have a config.ru file in the top directory of your application, its contents will be used as the rackup script for your Rack-based application. You will probably need to specify framework and application gems in config/warble.rb.

See the examples in the JRuby-Rack project to find out how to configure Warbler to package Camping and Sinatra applications.

Configuration Auto-detect Notes

Custom Configuration

The default configuration puts application files (app, config, lib, log, vendor, tmp) under the .war file's WEB-INF directory, and files in public in the root of the .war file. Any Java .jar files stored in lib will automatically be placed in WEB-INF/lib for placement on the web app's classpath.

web.xml

Java web applications are configured mainly through the web.xml file. Warbler creates a suitable default file for you for use. However, if you need to customize it in any way, you have two options.

For more information on configuration, see Warbler::Config.

Troubleshooting

If Warbler isn't packaging the files you were expecting, there are several debug tasks available to give you more insight into what's going on.

Source

You can get the Warbler source using Git, in any of the following ways:

 git clone git://kenai.com/warbler~main
 git clone git://git.caldersphere.net/warbler.git
 git clone git://github.com/nicksieger/warbler.git

You can also download a tarball of Warbler source at http://github.com/nicksieger/warbler/tree/master.

License

Warbler is provided under the terms of the MIT license.

 Warbler (c) 2007-08 Sun Microsystems, Inc.

Warbler also bundles several other pieces of software for convenience. Please read the file LICENSES.txt to ensure that you agree with the terms of all the components.