Vendor Jars

I'm hanging out at JRubyConf today, and I got all inspired to contribute something to the community. So I decided to put together a little plugin for auto-loading jars into a JRuby on Rails project. One of the key advantages of using JRuby instead of MRI is the availability of all of the mature Java libraries. In JRuby, you have the ability to easily wrap those libraries and access them directly from your Ruby code. The process is pretty easy, you just require each jar that you want to use, just like you'd require a gem, or another .rb file. But there is no consistent pattern for this -- no convention for where to place those files. What I wanted was to have a jars folder under vendor where you could just drop jars and have them automatically required in your app. The end result is a ridiculously simple plugin I've imaginatively called Vendor Jars.

To install it, just cd to the top-level folder of your rails app and run

script/plugin install git://github.com/diminish7/vendor_jars.git
This will add the plugin to your vendor/plugins folder, and it will create a vendor/jars folder. Then, for any Java jar that you want to be accessible from your JRuby code, just drop the jar into that vendor/jars folder, and it will automatically get required at startup.

That's it. I know it's not much (it's like 4 lines of code or something) but I feel like I write that same code every time I do a new JRuby app, so, simple as it is, I think it'll be useful.