Maven and JRuby on Rails

I am currently investigating using JRuby on Rails with Maven 3, and whilst I am still far away from getting a proper running application, I think it is worth summarizing what I have found so far.

JRuby Maven Plugins

An excellent starting point is the set of plugins called JRuby Maven plugins (not to be confused with jruby-maven-plugin to write JRuby mojos, rather than using Jelly). The information is a bit sparse and outdated, but after while tinkering with them, I found them pretty easy to use. To use them, you must first have a JRuby on Rails project:

sebastien@greystones:/tmp$rvm list  rvm rubies  => ruby-1.9.2-head [ x86_64 ] jruby-1.5.6 [ amd64-java ]  sebastien@greystones:/tmp$ rvm jruby
sebastien@greystones:/tmp$ruby -v jruby 1.5.6 (ruby 1.8.7 patchlevel 249) (2010-12-03 9cf97c3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [amd64-java] sebastien@greystones:/tmp$ rails new myapp
create
create  Rakefile
create  config.ru
create  .gitignore
create  Gemfile
create  app
create  app/controllers/application_controller.rb
. . .


Once the rails project is created, you can now use the jruby-maven-archetype:

sebastien@greystones:/tmp$mvn archetype:generate -DrailsVersion=3.0.3  (Documentation says it is -Drails.version=3.0.3, but it is incorrect). The jruby-maven-archetype currently is number 21, so you can enter its number at the prompt, as well as its current version number (0.23.0), and then the groupId, the artifactId of your app (here myapp, like the rails app), the version, and the package name. Once the application is set up, you should be able to run it with the following command: sebastien@greystones:/tmp$ cd myapp
sebastien@greystones:/tmp$mvn rails3:server  You should then be able to access your app at http://localhost:3000/. bundle command bundle is a great addition to rails 3; unfortunately, it is not available from maven commands provided by JRuby maven plugins yet. That’s why I wrote the following addition to these plugins, bundle-maven-plugin. It is still ongoing work, so it is still a bit rough, but it should do the trick for bundle install, update, package, exec and config commands. Making a war This is the next step in the process… and I haven’t had the chance to get to it yet. However, it looks like warbler is the tool for this task, so I’m guessing this will be another post. Comment 1.$ mvn package

should build the war file in target. and

\$ mvn jetty:run

should start a jetty server in development mode.

· 2011-03-09 20:20 · #

 Name Remember Email Website Message Textile help