Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby wrappers for javac and jar that don't just exec

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 tasks
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 pangolin.gemspec


Ruby wrappers for javac and jar that don't just exec.

Ant is a nice tool for writing Java build scripts, but Rake is nicer. The only thing missing from Rake is a way to run javac, jar and your JUnit tests, and although it's easy to run these with exec you have to wait for the JVM to start for each invocation. In combination with JRuby this gem lets you run javac, jar and junit in your Rake scripts without exec'ing, and you don't have to write XML to do it. Pangolin uses the the programmatic interface to Javac, Java's ZIP file creation capabilities and the JUnit command line runner to do it's magic.


require 'pangolin'

task :compile do
  javac FileList['src/**/*.java'], :destination => 'build', :class_path => FileList['lib/*.jar']

task :dist => :compile do
  jar 'dist/my-awsome-app.jar', FileList['build/**/*.class'], :base_dir => 'build'

task :test => :compile do
  test_classes = FileList['build/**/Test*.class'].pathmap('%{build/,}X').gsub('/', '.')

  junit test_classes, :class_path => FileList['build', 'lib/*.jar']

There are more examples in the examples directory (just cd to one of the directories under examples and run +jruby -S rake+, or jrake if you have it).


Pangolin is available as a gem from Gemcutter:

sudo jruby -S gem install pangolin -s

Command style

Many Rake add-ons look like this: do |spec|
  spec.spec_opts << '--options' << 'spec/spec.opts'
  # ...

I think it ruins the DSL illusion, and I prefer to write tasks that contain commands, more like how cp, rm and sh work in Rake.


Don't forget that since JRuby 1.3 you can minimize the startup by using the built-in Nailgun support. Run

jruby --ng-server &

to start a Nailgun server and then run Rake with this command

jruby --ng -S rake

you'll notice that the startup time decreases significantly the second time you run it. To avoid having to write all that every time you want to build create an alias, I call mine jrk.


Even though the whole rationale behind Pangolin is to avoid exec it wouldn't be much effort to support non-JRuby runtimes since at least the javac command needs to build the command string anyway.


Pangolins eat ants for breakfast.

Something went wrong with that request. Please try again.