How do I add optional dependencies to rubygems, as it does not support it?
Use cases:
- I have a library that does either depend on Backports, Extlib, Facets or ActiveSupport. In the past I just did not add any of this dependencies, as people could choose (read: it would play nicely with whatever they were using), but people complained a lot about the library not working out of the box, or they would believe it depended on ActiveSupport (which in some cases is a no go for some people). So at the moment it depends on Backports, as it is the most minimal. Though that means people will install Backports if they install my library, even though they might not use it at Runtime.
- I want to depend on different gems depending on the environment (i.e. Johnson on MRI/Rubinius, TheRubyRhino on JRuby, Lyndon on MacRuby).
One approach I though about is highjacking extconf.rb
. I could do system checks there. However, this feels wrong. Moreover, if this is the only way, how do I go about it? How do I trigger installing additional gems from there? system 'gem install ...'
?