mkristian / ruby-maven

repo moved to
https://github.com/takari/ruby-maven
MIT License
28 stars 7 forks source link

Compatibility with gem-maven-plugin #2

Closed ddossot closed 10 years ago

ddossot commented 10 years ago

Not sure if I missed something in the user guide or if this is a genuine feature request, but here you go :)

I'm trying to use rmvn with gem-maven-plugin and face the issue that the gems defined in the Gemfile are not added to the generated POM as gem dependencies, like:

    <dependency>
        <groupId>rubygems</groupId>
        <artifactId>deep_merge</artifactId>
        <version>1.0.1</version>
        <type>gem</type>
    </dependency>

Without this type of entry in the POM, the gem-maven-plugin doesn't bring the gems on the classpath, which causes issues when further trying to package an application with its gems.

mkristian commented 10 years ago

not sure how your Mavenfile or pom.rb looks like but adding gemfile somewhere inside project (pom.rb) or Mavenfile will add the gems from Gemfile (might have an issue with Gemfile.lock). with using gemfile the gem-maven-plugin will be configured as well but you can reconfigured it to your need anytime after the gemfile declaration.

ddossot commented 10 years ago

That sounds great, thanks for the quick response.

If I add gemfile to my Mavenfile, I'm receiving a stack that starts with:

$ rmvn clean package
[INFO] Scanning for projects...
/home/ddossot/dev/projects/unbounce/lp-leads-viewer-vertx/.tesla.Mavenfile
ArgumentError: wrong number of arguments calling `require` (0 for 1)
      do_dependency at /home/ddossot/.rvm/gems/jruby-1.7.9/gems/maven-tools-0.34.2/lib/maven/tools/dsl.rb:863

No doubt I'm doing something horribly wrong here :)

mkristian commented 10 years ago

would it be possible to share your Mavenfile with me ? so I can make sure it works before releasing a new maven-tools gem !

the fault is on maven-tools side since your gem has a 'require' option which should be ignored instead of doing some strange things with it ;)

ddossot commented 10 years ago

Here it is - with some values changed, to protect the innocent ;) :

# -*- mode:ruby -*-
group_id      'net.acme.vertx'
artifact_id   'my-vertx-service'
version       '1.0.0-SNAPSHOT'
name          'my vertx service'
parent        'net.acme.vertx:vertx-jruby-module-parent', '1.0'

The parent POM contains a bunch of plug-ins, including the gem-maven-plugin.

mkristian commented 10 years ago

thanx, the Mavenfile is not the problem ;)

I guess you also added 'gemfile' at point in time.

anyways I pushed a fixed maven-tools gem which allows the use of :require => 'something' or so inside the Gemfile. just

$ gem update maven-tools

and ruby-maven should pick the new gem then. let's see if this was all the problems with your Gemfile ;)

ddossot commented 10 years ago

First thanks a lot for your continuous support.

I indeed do have a Gemfile: it's where I have listed all the Gems of my project.

To give you an idea where I'm coming from: I'm migrating a Vert.x jRuby project from a pure Maven build, where the gems are defined as dependencies in the pom, to ruby-maven where I'm trying to have the gems in a Gemfile and some Maven specific stuff (parent project mainly) in Mavenfile.

Part of the parent pom takes care of packaging the Vert.x module, which includes the gems packaged as a JAR thanks to the magic of gem-maven-plugin that brings them in target/rubygems.

I've updated maven-tools to 0.34.3 but the build still acts as if the gem-maven-plugin doesn't see the gems defined in Gemfile. I've tried adding gemfile to my Mavenfile but to no avail.

mkristian commented 10 years ago

that is about what we/I do with those projects:

https://github.com/jruby/jruby/tree/master/ext/openssl https://github.com/jruby/jruby/tree/master/ext/ripper https://github.com/jruby/jruby/tree/master/ext/readline https://github.com/sonatype/nexus-ruby-support/blob/master/nexus-gem https://github.com/jruby/warbler

a ruby project part of maven build.

first you should add the two properties to your Mavenfile:

properties( 'tesla.dump.pom' => 'pom.xml', 'tesla.dump.readOnly' => true )

but be aware that it will overwrite the pom.xml so better choose a different filename first.

ruby-maven basically works just takes the Mavenfile and creates a pom.xml which will be used to execute maven. you definitely need

gemfile

directive. that seems to fail - I know that ruby-maven does not support the full bundler DSL.

maybe just try a simple Gemfile with a single gem first and have a look at generated pom.xml and see if it what you expect. then it would be helpful what directive inside the Gemfile makes ruby-maven fail. the next days I would like to push a new release

and I am happy to get another real world project (yours) working !!

-christian

ddossot commented 10 years ago

If I trim down the Gemfile and use gemfile , it works. You are right, the issue was due to:

gem 'codeclimate-test-reporter',                  require: false

in the Gemfile (no version specified).

Thanks again~

mkristian commented 10 years ago

great, the combination of no version and extra option is still missing in my tests ;) - thanx