Managing environment variables for multiple projects

I have a few projects I work in intermittantly which require different versions of Grails and Java JDK. I need to simplify the process of switching between these. Today, the JAVA_HOME and GRAILS_HOME changes are not being fully accepted, either by windows8 (like admin has his own copy that's not updated) or my local repo/cache is not thoroughly cleaned and leads to compile errors. I'd like the project to take these values from a local project directory, similar to how setenv.bat is used by catalina.bat/start.bat

Has anyone had success with this?

One idea I have is using a script of my own to do the setenv steps prior to calling 'grails compile'. Reason for this is that $PATH determines which version of grails its going to call. I may even have to backup the $PATH, say $PATH2, and omit java and grails from path2. In this way, I can set $path to $path2+ java + grails. Last step would be to pass any args on to grails to execute. Example: mygrails test-app -integration.... could do setenv and would call grails $1 $2...

Problem with this approach is, each time I get a new checkout from repo, I would have to copy my scripts..or check them in, which is not desirable. Ideas welcome

Please sign in to leave a comment.