Friday, July 30, 2010

Grails Quick Tip : Work Directory

Yesterday I was required to work on a branch of one of our projects and came across a little predicament : The branch had different plugin versions than the trunk I was currently working on.

Grails stores all the plugin classes, files and resources in ~/.grails, the projects are then divided out by their Grails version and project name. In this case the Grails version and of course the project names matched. I was a little peeved that I might need to blow away plugins and re-download if I was switching branches etc. What is one to do at a time like this??? Cry??? No..... just add the following line to BuildConfig.groovy under the grails-app/conf directory :

grails.work.dir="work"

This will simply place all your project meta-data into your project base dir /work... No need to blow away your previously downloaded plugins. Tears averted! I think this was introduced in 1.1.

One cool plus is that Intellij IDEA picks up on this (as with a lot of changes in BuildConfig.groovy these days) and allows you to continue with no pesky configuration changes! Also, this folder doesn't need to be in your grails-app, it can be anywhere, just use absolute paths.

Hope this help avert some crying developers.... they aren't much fun (except when Captain Morgan is the cause)

:) Thanks!