-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jeweler should allow management of dependencies in Gemfiles by platform #170
Comments
In general, jeweler just is wrapping gemspecs. As far as I understand it, gemspecs don't allow platform-specific dependencies, so it'd be kinda hard to do. Just to make sure I understand what you mean, could you point me at an example please? |
An example would be this Gemfile: https://github.com/eedrummer/quality-measure-engine/blob/develop/Gemfile On line 5, I load the bson_ext gem, but only if running under MRI. Now Jeweler looks at this Gemfile and adds bson_ext as a dependency when building the gemspec. I would like to be able to tell Jeweler to ignore gems that have platform specific requirements (in this case, I want my gem to be able to run under both MRI and JRuby). So I would like to see a mechanism to deal with platform dependencies declared in the Gemfile and how they get added to the gemspec. |
While bundler has support for this, I'm pretty sure that rubygems itself does not. That is to say, there's no way to tell a gemspec: gemspec.add_dependency 'cover_me', '>= 1.0.0.rc5', :platforms => :ruby_19 You could conditionally add this to the gemspec, but remember, this is a gemspec generated to eventually become a gem and eventually pushed to rubygems.org. If you do this from ruby 1.9, you'd end up creating the gem with that cover_me depended on everywhere, not just on ruby 1.9. That's what I mean by rubygems needing to support it directly |
this is a problem. at the moment jeweler add rmagick and rmagick4r as runtime dependency. it's possible to exclude both gems? it a good workaround. user muss choice self wich version they need, and service like travis-ci use Gemfile and work, too. |
@traxanos that sounds like a different issue. You're talking about a gem that can use one of 2 possible libraries, yeah? This issue is mostly about that but for platform specific gems. |
Hi guys, ran into the same problem today. What I use in a normal gemspec to do this is: gem.add_dependency "jruby-openssl" if RUBY_PLATFORM == "java"
gem.add_dependency "openssl" if RUBY_PLATFORM == "ruby" You can also use it inside a jeweler task. Can this be added to the jeweler automatic translation of the Gemfile? |
nive idea +1 |
+1 |
1 similar comment
+1 |
I noticed this issue is old, but is there any solution to this? |
To my knowledge, Gem::Specification still doesn't support per-platform dependencies :( On Oct 12, 2012, at 4:31 PM, Joel Asher Friedman notifications@github.com wrote:
|
What about the way flori/json does it? It's more complicated, but works. Essentially you have 2 gemspecs, one for each platform. Thus you build and release 2 gems, yet again one for each platform but having the same name. |
Those are good examples to look at, for sure. It is a pretty complicated work flow though. I have never done a multi platform gem though, so I'm not sure I know that workflow well enough to jewelerify it though. |
Any news? What about the |
@redox that still has the same problem. As long as it's calling 'gem' conditionally, it'd have this problem. I hadn't heard of any changes in rubygems, but I haven't been looking hard :( I haven't done a multi-platform gem yet either, so haven't had a ton of motivation to implement. I'd be happy to review any PRs to add this though. |
Right now you can do it with a terrible monkey patch like this: Jeweler::Tasks.new do |s|
...
# load non conditional dependencies from Gemfile
# monkey patch for conditional dependencies
def s.to_ruby
# see https://github.com/technicalpickles/jeweler/issues/170
result = super
fail "Unexpected gemspec:#{result}" unless result.chomp!("\nend\n")
result << "\n s.add_dependency('jruby-pageant', ['>= 1.1.1']) if RUBY_PLATFORM == 'jruby-pageant'"
result << "\nend\n"
result
end
end |
If this is still a wanted feature, please let me know, otherwise I will be closing this issue shortly. |
Yes, this is still something I would love to have to easily support |
Keeping this on the list. |
Right now, Jeweler pulls in all dependencies from a Gemfile, regardless of platform dependency. It would be nice if there was a way to restrict the inclusion of dependencies based on their platforms.
The text was updated successfully, but these errors were encountered: