maven plugin to handle rubygems in a maven way. including support for rspec, rails, cucumber, rake, etc
Java Ruby JavaScript Groovy
Pull request Compare This branch is 2 commits ahead, 658 commits behind torquebox:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


maven plugins for jruby

my problem with maven vs. gem

both project try to solve the same problems. I just wrote a gem for jruby only, now I need to include some java code as a jar file and I depend on 3rd party jars. what shall I do ? pack them all up with the gem. but then I loose all dependency info from my jars and I cannot share them and I might run into version conflicts later since the gem packed jar file is just a file like any ruby file.

maybe these plugins helps projects where ruby and java lives side by side. maybe you have a java project and need some rubygems for your ruby scripting. or the other way around you have a ruby project and want to use java libraries with a lot of dependencies. have look at these plugins they might help you to manage the java world and ruby world in the same manner.

how to use it

there are plenty of integrations test in src/it of each plugin. so the best is to look through those examples.

nice plugin prefixes

add following to your settings.xml (see also

  . . .
h3. pom.xml config

important is to declare the rubygems repository whenever you have gem artifacts as dependencies:


here there are a few things to mention: update-policy is set to ‘never’ to tell core maven to not do it, the gem plugin will take of this on daily manner. the checksum-policy is set to ‘ignore’ since there are no checksum files – anyways you will see some error messages with the checksum which can be safely ignored. the gem layout works only with maven3 (maven2 produces some error of not finding the layout with hint ‘gem’)

jruby-maven-plugin, rails2-maven-plugin, rails3-maven-plugin, rspec-maven-plugin

for example the jruby plugin declaration looks like this:

      . . . .
      . . . .

more help you get with

  • mvn ruby:help
  • mvn rails2:help
  • mvn rails3:help
  • mvn rspec:help

the prefix is ruby since there is already a jruby plugin on codehaus with the prefix jruby.


      . . . .
      . . . .

please not the extensions set to true – only with this setting the gem plugin can manage the gem artifacts properly

more help you get with

mvn gem:help

common parameters for all goals

please use ruby:help, gem:help, rspec:help, rails2:help and rails3:help to get more info about the parameters for a specific goal.

the first name is the system property which can be set either via the commandline ( or via the properties section in the pom.xml. and the second name is the name for configuration part of the plugin.

  • jruby.fork (fork) – default: true
  • jruby.verbose (verbose) – default: false
  • jruby.home (home) – default: none
  • jruby.version (version) – default: taken from dependency or 1.5.0
  • jruby.jvmargs (JVM args) – default: -client -Xmx384m
  • gem.home (gemHome) – default: target/rubygems
  • gem.path (gemPath) – default: target/rubygems
  • (launchDirectory) – default: current-directory when there is no pom, or basedir

common parameters for all goals from gem, rpec and rails plugins

  • “offline command line switch -o” (offline) – default: false
  • gem.includeOpenSSL (includeOpenSSL) – default: true
  • gem.forceVersion (forceVersion) – default: false
  • gem.useTransitiveDependencies (useTransitiveDependencies) – default: false

any goal has the properties ‘jruby.version’ and ‘jruby.fork’. you can set via the command line

common parameters for all goals from rails2/rails3 plugins

  • args (args) – default: none
  • rails.dir (dir) – default: src/main/rails or basedir
  • rails.env (env) – default: none (but rails defaults to development)


the default behaviour is to fork jruby which allows to use a custom gem home/path wiith a default location of target/rubygems. there maven will install all gems which were declared as dependency (including transitive gem depedencies). important: this does not work if you use the embedded jruby (fork=false)!

after a mvn clean you can be sure that there is just one version for given gem present in target/rubygems. maven also resolves the version needed which might be different from what you get if you use rubygems or bundler. you can always use an explicit dependency to select a specific version of a particular gem.

note: with rubygems any version with an alphabet is a “prerelease”. for maven this is not the case and it treats all versions in similarthe same manner. to rectify this is a pending issue.


suppose you have already a rails-2.3.5 application inside a myapp directory. have a terminal open in the parent directory of this application and execute following command:

mvn archetype:generate -DarchetypeCatalog=

  • there you have only one choice – so choose it :-)
  • for the groupId just use “rails” or whatever you desire
  • the artifactId is important and must match your application directory – i.e. myapp
  • the version and package just take the default

the archetype is stupid and uses rails version 2.3.5 as default and sqlite3 as database and it does not matter what the rails application actually uses. in case you need something else do as follow:

mvn archetype:generate -DarchetypeCatalog= -Drails.version=3.0.0.beta3 -Ddatabase=mysql

for some little more info what you can do with this start the server (as usual or) with

mvn rails2:server

and open the browser at http://localhost:3000/maven.html