mkristian / ruby-maven

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

Download all gem versions even with Gemfile.lock #5

Closed ddossot closed 10 years ago

ddossot commented 10 years ago

We're facing a strange situation :sweat:

We have a bundler generated Gemfile.lock and a ruby-maven build that uses a Mavenfile, which in essence refers to a parent pom and contains the gemfile directive. The parent pom configures the gem-maven-plugin as such:

<plugin>
    <groupId>de.saumya.mojo</groupId>
    <artifactId>gem-maven-plugin</artifactId>
    <version>${ruby.maven.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>initialize</goal>
            </goals>
            <configuration>
                <gemPath>${rubygems.directory}</gemPath>
                <gemHome>${rubygems.directory}</gemHome>
            </configuration>
        </execution>
    </executions>
</plugin>

When building with rmvn, each version of each gem is downloaded as if the Gemfile.lock didn't exist, which literally takes hours.

If I run rmvn help:effective-pom, I see that the gems appear three times:

All this looks nice and correct so I can not understand why I still see all the versions downloaded.

I even tried -Pgemfile_lock,-gemfile to forcefully enable/disable the profiles, but to no avail.

Any light you could shed on the problem would be really appreciated. Thank you.

mkristian commented 10 years ago

well, that is quite a difficult one since it needs to be addressed before maven starts resolving the gem artifacts - and there is no hook for it in maven itself (as far I understand things). ruby-maven does have natural hook - it first starts Ruby ;)

so I think something can be done using the bundler API to get most pom.xml (reduced to only dependencies) in place before regular maven starts.

beside that I just can repeat what I wrote the other day https://github.com/torquebox/jruby-maven-plugins/issues/57#issuecomment-46668167

ddossot commented 10 years ago

OK, thanks again for your time and answer. Sorry for not having found the other issue, I could have just commented on it.

I guess I got confused when I saw that the POM was correct, with strict versions defined ; and that the ranged dependencies were in a specific and inactive profile. I was expecting that because the active dependencies in the POM only contained strict versions for the Gems, and because the project has a Gemfile.lock pre-computed by bundler, the logic for ranged versions would not kick in.

Oh well, better not blow up that Maven repo then :sweat_smile:

mkristian commented 10 years ago

maybe I could just use the Gemfile.lock as is to setup the gems and attach them to maven project without the need to declare them as gem artifacts inside the POM but resolve them without there "transitive dependencies"

let's see if that is possible, at least it would meet maven and bundler on middle ground.

ddossot commented 10 years ago

That would be awesome :smile:

I do realize that it's hard to accommodate all these different workflows that crazy devs are setting up with your tools :blush: On our side, we build Ruby modules for Vert.x: our Ruby devs do everything with Bundler+Rake then our continuous integration assembles the module with ruby-maven. That's why we have this environment where Bundler has resolved all the dependency versions in a Gemfile.lock and ruby-maven is expected to pick-it up...

Anyway, thanks again for your assistance.

mkristian commented 10 years ago

https://github.com/torquebox/jruby-maven-plugins/issues/57#issuecomment-46668167

that first step was easy ;)

now I have to fix ruby-maven and make sure the "none" profile gem artifacts are not declared - thanx for pointing that fact out. it looks like ruby-maven starts to play well with bundler now ;)

ddossot commented 10 years ago

:thumbsup:

mkristian commented 10 years ago

it relased it: ruby-maven-3.1.1.0.7

BTW the reduced traffic is very helpful and actually made things like this possible/feasible:

https://github.com/jruby/jruby/wiki/Rack-Application-with-JBundler-on-Heroku https://github.com/jruby/jruby/wiki/Running-Minitest-or-Rspec-over-serveral-JRuby-versions-with-Ruby-Maven

ddossot commented 10 years ago

Happy to confirm this works perfectly, thank you so much!