I'm using Homebrew "The missing package manager for OS X" for a while now but when it come's to Grails I still install it manually: until now! Installing the most recent version of Grails using Brew is straight forward:

$ brew install grails

But the main reason for me to install Grails manually is the fact that I 'd like to be able to install multiple versions and select a specific version for the project I'm working on. I just found out that that's also very easy with Homebrew. If the desired version of Grails is not installed install it using Homebrew. Start by unlinking the current version.

$ brew unlink grails

Then retrieve the available Grails versions.

$ brew versions grails

2.1.1 git checkout 4ca74c7 /usr/local/Library/Formula/grails.rb
2.1.0 git checkout 0dcf6e7 /usr/local/Library/Formula/grails.rb
2.0.4 git checkout 624e065 /usr/local/Library/Formula/grails.rb
2.0.3 git checkout af73ab0 /usr/local/Library/Formula/grails.rb
... <left out> ...
1.2.1 git checkout e4b66ce /usr/local/Library/Formula/grails.rb

Install a specific version using the hash from the result of the brew versions grails command.

$ cd `brew --prefix`
$ git checkout 624e065 Library/Formula/grails.rb   # use output of "brew versions"
$ brew install grails                              # install grails
$ git checkout -- Library/Formula/grails.rb        # reset formula

Switch to the desired version of Grails using the following command.

$ brew switch grails 2.0.4

Once the desired version of Grails is installed, switching to that version is straight forward. To switch back to the current Grails version use the following command.

$ brew switch grails 2.1.1
shadow-left