Discovering your grails application version
In many projects around, one of the requisites is that our customer should know what version of the application was running in the environment. The first approach that people reaches is to insert a comment in the HTML source code or some static page that contains this info.
Using grails, we manage our application versions using the set-version grails command as you should know. After creating your grails application, the default version your application assumes is the 0.1. After some development you’re highly recommended on changing this. There is infinite approaches on managing app versions, I really like this one:
grails set-version 20090403-1
That says this is the first (1) version of today (2009 april’s third). After that, whe you create your war, the version will be appended in the war file’s name.
Ok, now that you have your application “versioned”, you can retrieve it with this simple line:
def version = grailsApplication.metadata['app.version']
Simple and useful!!! This will get the grailsApplication reference, that can get this information for you.
Are you following me and reading my blog’s feed? Be the first to know when I publish some interesting article signing up to my feed and following me on twitter!
Comments(0)