Pull request Compare This branch is 526 commits behind torquebox:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


maven plugin for rails

this is the last release for rails 2.3.x

the maven plugin for rails3 will be part of the jruby-maven-plugins. this plugin is tidly coupled the jruby-maven-plugin and/or gem-maven-plugin that it makes more sense to keep things together – only install and deploy one time and rails3 is significant different to sseparate it from the current plugin.


this plugin mimicks partially what you can do with rake tasks which are part of rails as well copies some behaviour from the warbler gem. the meaning is to allow to handle rails totally from within maven, i.e. checkout the code and mvn package will build the war file or mvn rails:server starts the inbuild webserver with rails or mvn spec will run the rspecs or mvn jetty:run-exploded will build the war and runs it inside jetty, etc.

so people who familiar with maven should find it straight forward (I hope so) to use it. projects based on maven might find it helpful to use it. etc.


alternative rspec maven plugin


main implementation ideas

  • freeze rails
  • handle all gems by rails
  • unpack all gems dependencies
  • have two config files for the war file: pom.xml and web.xml
  • have a maven like directory tree and place the rails application in src/main/rails
  • allow (almost) all goals to run without pom.xml, i.e. can be used in every rails installation (with certain version restrictions – I guess)

minimal pom.xml

remark the jetty plugin is only needed to run the war file with an embedded servlet engine (jetty) from within maven.

<project xmlns="http://maven.apache.org/POM/4.0.0"
      <name>Saumya's Plugins</name>
        <!-- needed for sqlite3 or file based databases -->

the rails-maven-plugin makes sure that rails installation is frozen and the gem dependencies are unpacked prior to pack a war file.

minimal web.xml

"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    <res-ref-name><%= jndi %></res-ref-name>

sample application

a sample application can be found under the integration tests of maven src/it/demo. this example uses datamapper as ORM so there are little more gem as for usual rails application.


beside the war goal all other goal run on a standalone rails application as well with maven project

the standalone goal needs to call the goal full qualified, with a pom.xml the prefix rails works

console goal (script/console)

mvn de.saumya.mojo:rails-maven-plugin:0.1.0:console -Dargs=
mvn rails:console -Dargs=

generate goal (script/generate)

mvn de.saumya.mojo:rails-maven-plugin:0.1.0:generate -Dargs=
mvn rails:generate -Dargs=

spec goal (rake spec)

mvn de.saumya.mojo:rails-maven-plugin:0.1.0:spec -Dargs=
mvn rails:spec -Dargs=

rails_freeze_gems goal (rake rails:freeze:gems)

mvn de.saumya.mojo:rails-maven-plugin:0.1.0:rails_freeze_gems -Dargs=
mvn rails:rails_freeze_gems -Dargs=

gem_unpack_dependencies goal (rake gems:unpack:dependencies)

mvn de.saumya.mojo:rails-maven-plugin:0.1.0:gem_unpack_dependencies -Dargs=
mvn rails:gem_unpack_dependencies -Dargs=


make the parameters consistent. decide which ones can be changed via the commandline and which one can be set only through the pom.xml.

maybe more goals of rake tasks