I have a little trick that I have used for many years to switch back and forth between versions of development tools. For example, because of the work that I do day to day I often need to switch back and forth between different versions of Grails. Occasionally I will execute this trick while sitting with another developer or during a live coding presentation at a conference without even thinking about it. Often someone will notice and and stop me to ask "what was that?".

I have a directory below my HOME directory called Tools. This Tools directory is where I install development tools like Groovy, Grails, Gradle, Ant etc. For some of those tools, I may want to have numerous versions of the tool available. For example, I have the following subdirectories below Tools...

One limitation of that approach is it is a lot of tedious typing. Another is that the change would only apply to the shell where that was executed. Normally if I am working with a particular version of Grails, I want that version to be in play in all open shells.

Instead of pointing GRAILS_HOME at a particular version of Grails, I create a symlink at ~/Tools/grails and that link points to one of the specific Grails version directories. GRAILS_HOME points to that symlink. If I am currently using Grails 1.2.2 and I want to switch to 1.3.0.RC2, I just move the symlink and leave GRAILS_HOME and PATH alone.

Moving the symlink is easy enough but I simplify it further by defining aliases in my ~/.profile. Those look something like this...

Now if I want to use Grails 1.2.2 I just open a shell and type "gr122".

I use the exact same approach for other tools that I may want to easily move from version to version.

I do all of this on OS X. The same trick should work on Linux. I don't know enough about cygwin to know if this can work on Windows or not. I expect that it probably would.

That is all I have. It isn't any big deal but is one of those little things that over the years numerous folks have asked me about and then expressed that they liked it well enough that they were going to do the same.