Fork me on GitHub

Sunday, 23 September 2012

Working with more then one grails version on same environment

,
Typically  you have your grails installed into some directory, created environment variable GRAILS_HOME and you are ready to go.

But what if you have few projects with different grails versions? You can have different reasons for that, but nevertheless you need it.

Here is short tip how this process can be simplified, example for Linux (Ubuntu).
Usually I install all applications to /usr/local/. Let's try to work with two grails versions 2.0.0 and 2.1.1(latest for this period)
So after unpacking we have
/usr/local/grails-2.0.0
/usr/local/grails-2.1.1
Let's create link to any version of Grails
ln -s /usr/local/grails-2.1.1 grails
Now we have
/usr/local  $ ls -ld grails*
lrwxrwxrwx  1 root root   23 Sep 23 15:05 grails -> /usr/local/grails-2.1.1
drwxr-xr-x 12 root root 4096 Dec 15  2011 grails-2.0.0
drwxr-xr-x 13 root root 4096 Sep 12 10:30 grails-2.1.1
and variable
echo $GRAILS_HOME
/usr/local/grails
Let's use simple script to change grails version. Mainly the only thing we have to do is to reassign link /usr/local/grails to version we would like to use
#!/bin/bash
#Script for changing grails version

grailsVersion=$1
rootPath="/usr/local"
grailsLinkPath=$rootPath"/grails"
grailsPath=$grailsLinkPath"-"$grailsVersion

echo stitching to version $1
#Check if directory with new grails version exists before doing anything
[ -d $grailsPath ] && rm $grailsLinkPath && ln -s $grailsPath $grailsLinkPath && echo "version switched to "$grailsVersion || echo 'Directory '$grailsPath' not found'

2 comments to “Working with more then one grails version on same environment”

  • 4 October 2012 02:07
    Raul says:

    Check out this Project.

    https://github.com/freshgroovy/gvm

    delete
  • 4 October 2012 09:50

    Very impressive. Good to now there is a solution

    delete
 

Grygoriy Mykhalyuno Copyright © 2011 -- Template created by O Pregador -- Powered by Blogger