Skip to content

maven plugin to handle rubygems in a maven way. including support for rspec, rails, cucumber, rake, etc

License

Notifications You must be signed in to change notification settings

dobozysaurus/jruby-maven-plugins

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maven plugins for jruby

my problem with maven vs. rubygems

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 http://maven.apache.org/guides/introduction/introduction-to-plugin-prefix-mapping.html)

<settings>
  <pluginGroups>
    <pluginGroup>de.saumya.mojo</pluginGroup>
  </pluginGroups>
  . . .
h3. pom.xml config

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

 <repositories>
    <repository>
      <id>rubygems-releases</id>
      <url>http://gems.saumya.de/releases</url>
    </repository>
    <!-- and for prereleased gems
    <repository>
      <id>rubygems-prereleases</id>
      <url>http://gems.saumya.de/prereleases</url>
    </repository>
    -->
  </repositories>

alternatively use:

 <repositories>
    <repository>
      <id>rubygems-releases</id>
      <url>http://rubygems-proxy.torquebox.org/releases</url>
    </repository>
    <!-- and for prereleased gems
    <repository>
      <id>rubygems-prereleases</id>
      <url>http://rubygems-proxy.torquebox.org/prereleases</url>
    </repository>
    -->
  </repositories>

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

for example the rails3 plugin declaration looks like this:

  <build>
    <plugins>
      . . . .
      <plugin>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>rails3-maven-plugin</artifactId>
        <version>${jruby.plugins.version}</version>
      </plugin>
      . . . .

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.

gem-maven-plugin

  <build>
    <plugins>
      . . . .
      <plugin>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>gem-maven-plugin</artifactId>
        <version>${jruby.plugins.version}</version>
        <extensions>true</extensions>
      </plugin>
      . . . .

please not the extensions set to true – only with this setting the gem plugin can package and install gem artifacts.

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 (-Dmy.property.name=value) 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.version (version) – default: taken from dependency or 1.6.2
  • 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

note: these parameter names did change over the course of time of these plugins. most notable is the change from jruby.gem.home to gem.home and jruby.gem.path to gem.path.

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

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

rubygems

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 the same manner.

rails-maven-archetype (not maintained anymore)

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=http://github.com/mkristian/jruby-maven-plugins/raw/master/archetype-catalog.xml

  • 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=http://github.com/mkristian/jruby-maven-plugins/raw/master/archetype-catalog.xml -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

more info

on the blog http://blog.mkristian.tk/ you will find more info on how to use these plugins.

About

maven plugin to handle rubygems in a maven way. including support for rspec, rails, cucumber, rake, etc

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 67.3%
  • Ruby 30.7%
  • JavaScript 2.0%