You can do this with your warble config. If you haven't already done so, create your warble config file like this:
jruby -S warble configThis will create a file at config/warble.rb in your Rails app. Inside there you'll see all sorts of config settings for the JRuby environment.
What I wanted to do was output the SVN info on the site, so that when we were testing in the Glassfish environment we could see what revision we were working with. So I just had this little snippet of code:
`svn info` =~ /Revision: (\d+)/Spit that out on the page somewhere and everyone can see what revision they're working with!
revision = $1.to_i
However the hard part is getting this into the WAR. What you have to do is pass it as a parameter in the warble config, like this:
config.webxml.svn_revision = revisionWhen warble runs, it will output this into the web.xml file within the WAR, which will get passed to your server.
To access this value from within the Rails app, you need something like this:
if defined?(JRUBY_VERSION)If you're only ever running in JRuby then you don't need the if defined? junk.
revision = $servlet_context.getInitParameter("svn_revision")
The $servlet_context object is a Java object that represents the servlet context. I actually don't really know what that is, but a quick search of the docs gives a handy bit of info and the one you want is the getInitParameter method.