Wednesday, September 1, 2010

Same name - different projects...

Hi there!

Today I've faced a serious problem: branchy development in Grails. Sounds easy, right? Well... Let's examine this a little bit.

Grails store files in 4 different locations:

  1. The folder where you've unzipped the distro (GRAILS_HOME)

  2. The project's folder

  3. The project's "target" folder

  4. User's home/.grails/{version} folder

The problem is in the last one. What's bad about it while doing branchy development is that there's more than one application with the same name but different version. That causes all kind of issues ranging from random build errors, no auto-reload of artefacts to unexpected application behavior.

As usually with Grails there's an ultra-easy way of fixing this problem :) Here's the content of my grails.bat that does the trick:


@echo off

set GRAILS_HOME=C:/grails-1.3.4
set JAVA_OPTS=%JAVA_OPTS% -Divy.cache.dir=%CD%/target/libraries
set JAVA_OPTS=%JAVA_OPTS% -Dgrails.project.work.dir=target/work

%GRAILS_HOME%\bin\grails.bat %*


As you can see here everything is made project-specific. In "target/libraries" is the ivy cache (instead of home/.ivy2 which causes problems from time to time when working with other technologies such as JSF) and in "target/work" are the project's artifacts.

And live is gooooooooood again :)

No comments: