Tropical Software Observations

19 April 2011

Posted by Huiming

at 2:10 PM

0 comments

Labels:

Managing multiple Grails versions in development

In Grails development, it's not uncommon to maintain several projects with different Grails versions.

It's a PITA to switch between Grails versions during development because it requires the GRAILS_HOME environment variable to be updated, to point to the correct Grails directory.

Rescue My Ass
I added 2 new bash commands to make my life easy:

  • grls - list all available installed versions.
  • gr - set GRAILS_HOME to the specified version.

How to Use It
Beech-Forkers-MacBook:~ huiming$ grls
1.1.2
1.3.2
1.3.4
1.3.6

Beech-Forkers-MacBook:~ huiming$ gr 1.3.2
Beech-Forkers-MacBook:~ huiming$ grails
Welcome to Grails 1.3.2 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/huiming/work/tools/grails


How I Implemented It
First, I keep all Grails installations under a same directory:

Beech-Forkers-MacBook:~ huiming$ ls -d1 work/tools/grails-*
work/tools/grails-1.1.2
work/tools/grails-1.3.2
work/tools/grails-1.3.4
work/tools/grails-1.3.6

Then, add the commands into my ~/.profile file:

TOOLS=~/work/tools

function gr {
rm -f $TOOLS/grails && \
ln -s $TOOLS/grails-$1 $TOOLS/grails
}

alias grls="ls -d $TOOLS/grails-* | xargs basename | sed 's/grails-//g'"

export GRAILS_HOME=$TOOLS/grails
PATH=$GRAILS_HOME/bin:$PATH

Thanks to Jeff, as the idea is largely based on his solution.

0 comments: