Script for Running Grails Projects of Different Versions Simultaneously

18 / Jun / 2010 by Vivek Krishna 3 comments

Sometimes it is required that multiple Grails projects, hosted on a different Grails version, run simultaneously. In this case, while fixing bugs, you are required to run the application after switching the Grails version each time.

To handle this scenario, I wrote a utility shell script “runGrails” to use a particular version of Grails while running the scripts like run-app, test-app etc. The shell script contained these two lines:

export GRAILS_HOME=/opt/grails-$1
$GRAILS_HOME/bin/grails $2

This script was put in a location coming under the “PATH”. It is assumed that the different versions of grails are under directories named grails-<version> under /opt/.

Now, to run different projects, we can call the script as:

runGrails 1.3.1 "-Dserver.port=8082 run-app"

which will run the project with grails version 1.3.1 at port 8082.

PS: This works on *nix systems.

Hope this helps.


Tag -

Grails Linux

comments (3)

  1. Vladimir Grichina


    I have written more sophisticated script doing the same

    Apart from explicit version configuration it also can parse file and choose Grails version automatically.

  2. Vivek Krishna

    Hi Wolfgang,

    I tried out your suggestion and it works perfectly. Thanks for the tip! 🙂


  3. Wolfgang

    If you change the script to this:

    export GRAILS_HOME=/opt/grails-$1
    $GRAILS_HOME/bin/grails “$@”

    you don’t need the “” around the args, when you call the script, as all of them are passe through (except the first, the grails version, which is removed in the second line).


Leave a Reply

Your email address will not be published. Required fields are marked *