
Written January 9, 2009. Tagged Ruby, Ruby on Rails, Java, Rake, JRuby.
I just started working for a new employer. The site runs Rails on JRuby ("JRuby on Rails").
I found it a little annoying how an "org.jruby.Main" app would appear in the OS X dock when I did stuff like start the server, open a console or run the test suite. Running all this in parallel meant three separate apps in the dock. My colleagues experienced this also, but it didn't bother them enough to have looked into it.
I couldn't find anything on Google, strangely, but IRC was more helpful (thanks, nicksieger). I'm not familiar enough with JRuby to know if there is a better way, or if this has been changed in some later version than we're using, but:
The jruby app takes a --headless option, explained as "do not launch a GUI window, no matter what".
jake/rakeI run the test suite with jake spec, where jake is an alias:
alias jake='jruby -S rake'To get rid of the dock action, I just changed this to
alias jake='jruby --headless -S rake'Obviously, be careful with this if you expect to ever run non-headless stuff through jake.
script/server, script/console etcChange
#!/usr/bin/env jrubyto
#!/usr/bin/env jruby --headlessin your script/* files.
I'm very new to JRuby, so please do correct me if I'm wrong, or suggest better solutions if they exist.