I have a Rakefile that includes this:
Jeweler::Tasks.new do |gem|
# ...
gem.add_dependency('json')
end
The gemspec that this generates builds a gem that can’t be installed on jruby because the ‘json’ gem is native.
For jruby, this would have to be:
Jeweler::Tasks.new do |gem|
# ...
gem.add_dependency('json-jruby')
end
How do I conditionally add the dependency for ‘json-jruby’ when RUBY_ENGINE == ‘java’?
It seems like my only option is to manually edit the gemspec file that jeweler generates to add the RUBY_ENGINE check. But I’d rather avoid this, since it kind of defeats the purpose of using jeweler in the first place.
Any ideas?
After some more digging around, I’ve come to the conclusion that the problem here isn’t so much the limitation in Jeweler as it is a problem with how the
json-jrubygem is named.In a perfect world, the
json-jrubygem should be named justjson. That way when the gem file is built under JRuby (i.e.jgem build json-jruby.gem), the resulting gem file would be namedjson-1.4.3-universal-java-1.6.gem(RubyGems names the file based on the ‘platform’ property in the gemspec). When installed with the appropriate platform in the gem name, everything works transparently. There’s no need to explicitly requirejson-jruby. RubyGems uses the appropriate version automatically.I’ve contacted the maintainer of the
jsongem to see if he’d be willing to get json-1.4.3-universal-java-1.6.gem added to his gemcutter repo, but in the meantime you can download the drop-in jruby json gem here: http://roughest.net/json-1.4.3-universal-java-1.6.gem