jruby-gradle / jruby-gradle-plugin

A Gradle plugin for working with JRuby projects for fun and profit. Mostly profit.
http://jruby-gradle.org
Other
92 stars 38 forks source link

Ability to Install Gem Dependencies From a Path #102

Open blaines opened 9 years ago

blaines commented 9 years ago

It would be great if it would be possible to configure individual gems to be installed from a local directory like with bundler's :path option. This would be very useful for local development or even intra-project dependencies.

Here's the idea in code:

gems ('rubygems:activesupport:3.2.+') { path = '../somewhere/active_support' }

I believe @rtyler has something going in that direction already.

ysb33r commented 9 years ago

have you tried just doing

repositories {
  flatDir '../somewhere/active_support'
}
rtyler commented 9 years ago

@ysb33r I believe the problem with that approach to be that the structure of a gem in source code is much different than the sturcture of a gem that has been "installed" or "unpacked" for Ruby code to pick up and require properly.

The work in progress that I have locally implements a SelfResolvingDependency to provide the following DSL:

dependencies {
    gems 'rubygems:faraday:1.0'

    gems gemspec('path/to/jbundler.gemspec')
}

Where I'm leaning right now is that resolve() on the dependency will properly build the package such that the normal gem install machinery can handle it appropriately.

ysb33r commented 9 years ago

My suggestion assumed that you already had a packed gem in a folder.

However, I do get your point and I like the the use of a gemspec keyword. It will it readable and the intent expressed correctly.

rtyler commented 9 years ago

The work I have going on in groovy-gem might be able to help here, I'm not sure it's going to solve the problem outright though

mojavelinux commented 7 years ago

The real hangup here is that people using Gradle are locked out from using gems directly from a git repository or a locally built gem. That makes it almost impossible for them to help with testing.

mkristian commented 7 years ago

a local gem is matter of adding it lib directory of the local gem to ruby load-path. dito with checked out git repos. I do not if there are gradle plugins dealing with git repo checkouts. I do not think it is impossible but different from bundler. but I have to admit that I am not using the jruby-gradle-plugin in bigger project

mojavelinux commented 7 years ago

@mkristian While it's true that using a git clone allows you to put the files of the gem on the load path, it does not provide dependency management. The ability to use a gem from a path or git repository just like any other gem is one of the most valuable features of Bundler for development and testing (See http://bundler.io/v1.13/git.html). However, we lack that feature in the JRuby Gradle environment.

mkristian commented 7 years ago

@mojavelinux I tried to implement it when I worked on the jruby-maven-plugins and also here with the gradle plugin. I am also not the right person as I do not even use git and only temporary path declarations with ruby.

the moment I want to have reproducible builds, jruby-gradle needs some lock version plugin which makes the whole git and path part of more complicated as this is outside of the jruby-gradle domain.

creating a pom.xml on the fly is not the problem but we are not even able to convert the rubygems.org repo on the fly to maven repo for gradle to use with their dependency resolution. there is (or was when I look at it) no way to hook anything into gradle to do so. the local gem problem is not the same but goes into the same direction, as you need to hook into the core dependency resolver.

having said this, I will look at any PR and/or ideas addressing this issue, I personally had my experiments and trial in the direction and happy to help with anything promising.

mojavelinux commented 7 years ago

Thanks for that insight!

For reference, I was able to work out how to use the gem from git without the dependency management part. You can see instructions in the following thread.

https://github.com/asciidoctor/asciidoctor-pdf/issues/650#issuecomment-258338060

This could be taken one step further to have Gradle clone the repo and the JRuby Gradle plugin build the gem. I just haven't gotten to that part yet.