Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

iconara/pangolin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pangolin

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.

Example

require 'pangolin'

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

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

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

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

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).

Installation

Pangolin is available as a gem from Gemcutter:

sudo jruby -S gem install pangolin -s http://gemcutter.org

Command style

Many Rake add-ons look like this:

Spec::Rake::SpecTask.new(:spec) do |spec|
  spec.spec_opts << '--options' << 'spec/spec.opts'
  # ...
end

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.

Nailgun

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.

Upcomming

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.

Pangolin?

Pangolins eat ants for breakfast.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •