Managing gems with Maven?

Is there a way I can manage gem dependencies with Maven, so that they
are automatically downloaded, installed, and packaged in the final
jar?

Thanks,
-SS


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Stuart,
As far as downloading and installing, I’ve come up with the following
(using
jruby-rake-plugin):

<jruby.version>1.4.0dev</jruby.version>
<gem.options>–no-rdoc --no-ri --user-install</gem.options>
<required.gems>ci_reporter activesupport jruby-openssl rest-client
json-jruby ick</required.gems>
<testing.required.gems>rake rspec</testing.required.gems>

[snip]



org.jruby.plugins
jruby-rake-plugin
${jruby.version}


install-gems
process-resources

install-gems

${gem.options} ${required.gems}
${testing.required.gems}


clobber
clean

rake


${basedir}
clobber



runtests
test

rake


${basedir}
spec



rdoc
verify

rake


${basedir}
rdoc




[snip]

As far as installing gems as part of the jar…if someone can help here
I
would very much appreciate it. I’ve looked at rawr but it seems to be
oriented towards Rake-only-based projects and here we have a Maven
project
that calls Rake only for certain parts, but Maven takes the lead.

Hope this helps,
-Mario.


I want to change the world but they won’t give me the source code.

Hi Stuart,
Yes, that’s fixed in Trunk, which means you’ll have to build your own
JRuby.
It really isn’t at all hard but it does mean you have to either get the
1.3.1 sources and patch them, or get the latest trunk (which is what
we’re
building against). In my case we have our own Nexus repository so I’m
publishing builds there weekly or thereabouts.
-Mario.


I want to change the world but they won’t give me the source code.

Thanks, Mario. This mostly worked for me (pom.xml copied below).

But I did notice a problem: if the “install-gems” goal is configured
to run in the “process-resources” phase, it works the first time, but
fails every time thereafter when the gems are already installed (error
copied below).

The “install-gems” goal fails with a NullPointerException when run
directly at the command line.

I also encountered the same error with the missing ast.bat file,
described by Kristian at http://tinyurl.com/yavhwt8

Anyone know how to work around these, preferably without building my own
JRuby?

-SS

==== BEGIN pom.xml ====

1.3.1 --no-rdoc --no-ri --user-install hpricot --version ~>0.6.1 jruby-openssl json-jruby ... org.jruby jruby-complete ${jruby.version} ... org.jruby.plugins jruby-rake-plugin ${jruby.version} install-gems process-resources install-gems ${gem.options} ${required.gems} ${testing.required.gems}

==== END pom.xml ====

==== BEGIN maven error ====

[INFO] [jruby-rake:install-gems {execution: install-gems}]
[INFO] hpricot already installed
[INFO] jruby-openssl already installed
[INFO] json-jruby already installed
[WARNING] ERROR: While executing gem … (Gem::CommandLineError)
[WARNING] Please specify at least one gem name (e.g. gem build
GEMNAME)
[INFO]

[ERROR] FATAL ERROR
[INFO]

[INFO] Java returned: 1
[INFO]

[INFO] Trace
Java returned: 1
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:86)
at
org.jruby.maven.AbstractJRubyMojo.ensureGems(AbstractJRubyMojo.java:135)
at org.jruby.maven.InstallGemsMojo.execute(InstallGemsMojo.java:16)

==== END maven error ====


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Thu, Sep 24, 2009 at 7:00 PM, Stuart Sierra
[email protected] wrote:

Thanks. Â I downloaded trunk and installed it locally with Maven. Â That
took care of the missing asm.bat problem, but I still get errors when
my gems are already installed:

[WARNING] ERROR: Â While executing gem … (Gem::CommandLineError)
[WARNING] Â Â Please specify at least one gem name (e.g. gem build GEMNAME)

I’ve narrowed this down to the presence of a --version argument in the
gem command line. When the gem command includes “hpricot
jruby-openssl json-jruby” it works fine, provided the gems are already
installed. But it fails if hpricot is NOT already installed when it
tries to install an incompatible version.

When the command includes “hpricot --version ~>0.6.1 jruby-openssl
json-jruby” it succeeds the first time, but fails if the hpricot gem
is already installed!

I don’t know what to do about this, except to install hpricot in a
separate step. Madness!

-SS


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Thu, Sep 24, 2009 at 3:34 PM, Mario C. [email protected]
wrote:

Yes, that’s fixed in Trunk, which means you’ll have to build your own JRuby.

Thanks. I downloaded trunk and installed it locally with Maven. That
took care of the missing asm.bat problem, but I still get errors when
my gems are already installed:

[INFO] [jruby-rake:install-gems {execution: install-gems}]
[INFO] hpricot already installed
[INFO] jruby-openssl already installed
[INFO] json-jruby already installed
[WARNING] ERROR: While executing gem … (Gem::CommandLineError)
[WARNING] Please specify at least one gem name (e.g. gem build
GEMNAME)
[INFO]

[ERROR] FATAL ERROR

-SS


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs