Ruby2Jar - build JAR from Ruby script

Ruby2Jar build JAR from Ruby script. It copy gems, compile sources and package JAR. It is a easy way to distribute your JRuby application or to create Applet or Java Web Start.

You must have Java SDK to use JAR builder. Also you should run it from JRuby for correct platform in gems.

If program containt Java files it must be in ext/ dir. Source Java files without class files will be compiled.

Installation

Use Gem to download and install Ruby2Jar.

gem install ruby2jar

Usage

Add to your Rakefile:

require "ruby2jar"

PKG_NAME = "program"
PKG_VERSION = "0.1"

Ruby2Jar::Rake::JarTask.new do |jar|
  jar.files = FileList["lib/**/*", "bin/*"]
  jar.main = "bin/program"
  jar.name = PKG_NAME
  jar.version = PKG_VERSION
  jar.add_dependency "rspec"
end

Limitation

In current JRuby version (1.1.2) you can’t use Ruby file system functions and __FILE__ constant in JAR. So didn’t use Dir.glob to require all files in dir or somethink like this.

Gem config

Gem can contain building config java.yaml in gem root. Builder will find list of exclude file patterns in jar.exclude config node.

License

Ruby2Jar is licensed under the GNU General Public License version 3. You can read it in LICENSE file or in www.gnu.org/licenses/gpl.html .

Author

Andrey “A.I.” Sitnik <[email protected]>