Friday, October 2, 2009

Running Multiple Versions of Groovy or Grails

I use Cygwin on my Windows system to run Groovy and Grails applications. I have several versions of both Groovy and Grails on my system. Sometimes I need to run for example an application with Groovy version 1.6.4 or 1.6.5, or a Grails application with version 1.1 or 1.1.1. I set up aliases for all versions I want to run in my ~/.bashrc so I can pick the Groovy or Grails version I need without much effort.

alias groovy164='/usr/java/groovy/groovy-1.6.4/bin/groovy'
alias groovyConsole164='/usr/java/groovy/groovy-1.6.4/bin/groovyConsole'

alias groovy165='/usr/java/groovy/groovy-1.6.5/bin/groovy'
alias groovyConsole165='/usr/java/groovy/groovy-1.6.5/bin/groovyConsole'

alias groovy17beta1='/usr/java/groovy/groovy-1.7-beta-1/bin/groovy'
alias groovyConsole17beta1='/usr/java/groovy/groovy-1.7-beta-1/bin/groovyConsole'

alias grails111='/usr/java/grails/grails-1.1.1/bin/grails'
alias grails11='/usr/java/grails/grails-1.1/bin/grails'
$ groovy164 --version
Groovy Version: 1.6.4 JVM: 1.6.0_14

$ groovy165 --version
Groovy Version: 1.6.5 JVM: 1.6.0_14

$ groovy17beta1 --version
Groovy Version: 1.7-beta-1 JVM: 1.6.0_14


tomas said...

this won't work with major versions of grails since it uses the GRAILS_HOME variable to do some things. You will run into a bad class error ( at least on a mac ).

Jeff Brown has an alternative solution for grails here - http://javajeff.blogspot.com/2010/04/switching-versions-of-grails-and-other.html

mrhaki said...

@Tomas: thank you for your comment. I am on Mac since the beginning of this year so I will use your suggested link.

Post a Comment