Can I specify that a gem is for JRuby only?
Is there something I can put in my .gemspec to indicate that the gem will only work with JRuby? I'm working on a gem that wraps Java libraries, and so requires JRuby. I couldn't find any information on this. It seems like you can only specific platform and (numeric) ruby version.
I'll of course document this requirement, but it would be nice if the gem simply fails to install with a reasonable error (or is not even available for install) with MRI Ruby. If there's nothing I can do in .gemspec, maybe I can do something else to make the installation fail?
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Nick Quaranto on 12 Jun, 2011 05:16 PM
Specifying the
javaplatform usually does it, and if you a build a gem from JRuby it should do that automatically. You could also set theplatformspecifically:http://guides.rubygems.org/specification-reference/#platform=
3 Posted by Adam Murray on 13 Jun, 2011 05:31 PM
Ok, it sounds like I should simply add:
platform = "java"
to my gemspec. I'll try that. Thanks!
4 Posted by Adam Murray on 16 Jun, 2011 07:58 AM
spec.platform = "java" in the gemspec seems to simply append "java" to the end of my gem name. It still installs into MRI ruby.
Someone suggested I use gem's (native) extension mechanism to write a script that would fail if not running under JRuby. But I can't seem to get this to work. I always get the error "cannot build native extension" even when my ext script does nothing.
I also tried building with both jgem and normal gem, but it didn't seem to make a difference. Although it's not clear to me if the local behavior when testing these things will be the same as when installing from rubygems.org. I only used the gem command "for real" so far. Next time I'll try to remember to build and push via jgem and see if that helps.
Maybe there's a bug report or enhancement request in here somewhere, but I guess it's not that big of a deal. I suppose if people can't RTFM or figure out a gem that starts with "j" and ends with "java" is intended for JRuby, that's not really not my problem ;)
Support Staff 5 Posted by Luis Lavena on 19 Jun, 2011 03:23 PM
Hello, let us know if you need anything else.
Closing this now.
Cheers.
Luis Lavena closed this discussion on 19 Jun, 2011 03:23 PM.