Skip to content

Instantly share code, notes, and snippets.

@ddeyoung
Created May 22, 2012 18:36
Show Gist options
  • Save ddeyoung/2770827 to your computer and use it in GitHub Desktop.
Save ddeyoung/2770827 to your computer and use it in GitHub Desktop.
Grails Environment Switching
# GRAILS
GRAILS_CELLAR=/usr/local/Cellar/grails
GRAILS_BIN=/usr/local/bin/grails
GRAILS_START=/usr/local/bin/startGrails
GRAILS_DEBUG=/usr/local/bin/grails-debug
GRAILS_CURRENT=$GRAILS_CELLAR/current
usegrails() {
gversion=$1
if [ -d $GRAILS_CELLAR/$gversion ]; then
if [ -d $GRAILS_CURRENT ]; then rm $GRAILS_CURRENT; fi && ln -s $GRAILS_CELLAR/$gversion $GRAILS_CURRENT
if [ -d $GRAILS_CURRENT ]; then rm $GRAILS_BIN; fi && ln -s $GRAILS_CELLAR/current/libexec/bin/grails $GRAILS_BIN
if [ -d $GRAILS_CURRENT ]; then rm $GRAILS_START; fi && ln -s $GRAILS_CELLAR/current/libexec/bin/startGrails $GRAILS_START
if [ -d $GRAILS_CURRENT ]; then rm $GRAILS_DEBUG; fi && ln -s $GRAILS_CELLAR/current/libexec/bin/grails-debug $GRAILS_DEBUG
else
echo "Grails $gversion not found"
fi
}
export GRAILS_HOME=$GRAILS_CURRENT/libexec
if [ ! -d $GRAILS_HOME ]; then
usegrails 1.3.7
fi
brew versions grails
# Install 1.3.7
git checkout 232acd0 /usr/local/Library/Formula/grails.rb
brew install grails
# Install 2.0.3
git checkout af73ab0 /usr/local/Library/Formula/grails.rb
brew install grails
# Update bash profile
## See .bash_profile snippet
# Switch grails at the command line
usegrails 1.3.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment