Warbler chirpily constructs .war files of your Ruby applications.
Warbler chirpily constructs .war files of your Ruby applications.
= Warbler {rdoc-image:https://img.shields.io/gem/v/warbler}[https://rubygems.org/gems/warbler] {rdoc-image:https://github.com/jruby/warbler/actions/workflows/ci.yml/badge.svg}[https://github.com/jruby/warbler/actions/workflows/ci.yml]
Warbler is a gem to make a Java jar or war file out of any Ruby, Rails or Rack application. Warbler provides a minimal, flexible, Ruby-like way to bundle up all of your application files for deployment to a Java environment.
Warbler provides a sane set of out-of-the box defaults that should allow most Ruby applications to assemble and Just Work.
== Compatibility
Warbler Status JRuby Java JRuby-Rack Rails Notes
------- ---------- ---------- ---- ---------- --------- ----------------------------------------------
2.1 Maintained 9.4 → 10.1 8+ 1.2 → 2.0 5.0 → 8.0 Rails 8.1 may be OK with pure Ruby webservers.
2.0 EOL 9.2 → 9.3 6+ 1.1 → 1.2 → 6.1
1.4 EOL 1.1 → 1.7 5+ ? ?For running wars with specific Java web servers, consult {JRuby-Rack compatibility}[https://github.com/jruby/jruby-rack#compatibility] to decide which JRuby-Rack version you may need to use. While warbler is compatible with multiple jruyb-rackversions, it does not know your target webserver, so you may need to further restrict your JRuby-Rack version
== Getting Started
Install the gem: gem install warbler.
Run warbler in the top directory of your application: warble.
Choose one:
For a web project, deploy your +myapp.war+ file to your favorite Java application server.
For a standalone applications, just run it: java -jar myapp.jar.
== Usage
Warbler's +warble+ command is just a small wrapper around Rake with internally defined tasks.
$ warble -T
warble compiled # Feature: precompile all Ruby files
warble config # Generate a configuration file to customize your archive
warble executable # Feature: make an executable archive (runnable + an emb...
warble gemjar # Feature: package gem repository inside a jar
warble pluginize # Install Warbler tasks in your Rails application
warble runnable # Feature: make a runnable archive (e.g. java -jar rails...
warble version # Display version of Warbler
warble war # Create the project war file
warble war:clean # Remove the project war file
warble war:debug # Dump diagnostic informationType warble to create the jar or war file.
== Features
Warbler "features" are small Rake tasks that run before the creation of the war file and make manipulations to the archive structure. For instance, the +executable+ feature makes your war file capable of running on its own, without a servlet container (using an embedded web server) :
warble executable warYou can either add features to the warbler command line:
warble FEATURE waror configure them in config/warble.rb to always be used.
config.features = %w(FEATURE)
Currently, the following features are available :
Features may form the basis for a third-party plugin system (in the future) if there is demand.
NOTE: Feature tasks must be included in the same command invocation and inserted before the +war+ task in order to take effect. For example, warble compiled; warble war does not compile and obfuscate +.rb+ sources because the second invocation of +warble+ does not run the +compiled+ feature and creates a basic war with the sources included, make sure you run :
warble compiled waror, if it's important that the war always be compiled, use the option above to put the feature in your config/warble.rb.
== .war or .jar?
War-based projects are for Rails, Merb, or Rack-based web applications. They usually contain a +config/environment.rb+ file, a +config/init.rb+ file, or a +config.ru+ file. The presence of these files are used to determine if the project is a web application, and thus a Java EE compatible war file is built for the project.
Jar-based projects are for standalone Ruby applications. Usually a Ruby application has a launcher script in the +bin+ directory and Ruby code in the lib directory. Warbler packages the application so that java -jar myapp.jar runs the launcher script.
== Jar Files
=== Gem Specification Files
If your project has a .gemspec file in the top directory, it will be used to configure the project's dependencies, launcher script, require paths, and the files to be included in the archive. For best results make sure your gemspec specifies all of the following attributes:
If your project do not have a .gemspec, Warbler will attempt to guess the launcher from the contents of the bin directory and use the lib directory as the lone require path. All files in the project will be included in the archive.
=== Bundler
Applications that use Bundler[http://gembundler.com/], detected via presence of a +Gemfile+, will have the gems packaged up into the archive along with the Gemfile. The Bundler groups named ":development", ":test" and ":assets" will be excluded by default, unless you specify with config.bundle_without in +config/warble.rb+.
Warbler supports Bundler for gems and git repositories, but not for plain path components. Warbler will warn when a +:path+ component is found in the +Gemfile+ and will refuse to include it in the archive.
=== JBundler (deprecated, experimental)
Applications that use JBundler[http://github.com/jruby/jbundler], detected via presence of a +Jarfile+, will have the jars packaged up into the archive. The JBundler gem is not needed for runtime since all jars are already part of the classloader.
JBundler is EOL; and this capability is thus deprecated for removal in a future release, and is not recommended for use. The recommended replacement is bundler with +jar-dependencies+ (bundled with modern JRuby); but requires some work for compatibility. See https://github.com/jruby/warbler/issues/481 for more details and contribute if you'd like this feature to be retained and supported.
== War Files
=== Rails applications
Rails applications are detected automatically and configured appropriately. The following items are set up for you:
See {the examples in the JRuby-Rack project}[http://github.com/jruby/jruby-rack/tree/master/examples/] of how to configure Warbler to package Camping and Sinatra apps.
=== Configuration Notes
== Custom Configuration
If the default settings are not appropriate for your application, you can customize Warbler's behavior. To customize files, libraries, and gems included in the .war file, you'll need a +config/warble.rb+ file. To generate one:
warble configEdit the +config/warble.rb+ to your taste. The generated file is fully-documented with the available options and default values.
=== Archive Layout
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 class-path.
=== web.xml
Java web applications are configured mainly through this file, and 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.
== Rakefile Integration
If you'd like to control Warbler from your own project's +Rakefile+, simply add the following code somewhere in the +Rakefile+ :
require 'warbler'
Warbler::Task.newIf you're using Bundler, you'll want to add Warbler to your +Gemfile+ :
group :development do
gem "warbler", :require => false
endNow you should be able to invoke rake war to create your war file.
== Troubleshooting
If Warbler isn't packaging the files you were expecting, use the +war:debug+ task to give you more insight into what's going on.
If you think you found a bug, please file one at https://github.com/jruby/warbler/issues.
=== Common issues with wars
If your app isn't working or starting up correctly:
Jruby-Rack version not compatible with JRuby version jruby-rack-2.0.0 requires Ruby version >= 3.4.0. The current ruby version is 3.1.7. jruby-rack-1.3.0 requires Ruby version >= 3.4.0. The current ruby version is 3.1.7. Warbler is compatible with multiple JRuby-Rack versions which have different JRuby requirements. You are trying to use a JRuby-Rack version which does not support your JRuby version; without using bundler to resolve dependencies.
:development group to install warbler, and ensure bundler is running with your intended runtime
JRuby version so the JRuby-Rack dependency is resolved correctly.Rack version compatibility
An exception happened during JRuby-Rack startup
no such file to load -- rack/chunked
You are trying to use Rack 3.x with a JRuby-Rack version that does not yet support Rack 3. Try upgrading to a compatible
JRuby-Rack version, or lock rack at a compatibile version with gem 'rack', '> 2.2.0'. Note that Rack > 2.2.0' or similar as a default/runtime dependency to y2.2 requires Rails gem 'rack', '
No open issues yet, or sync has not completed.