Created
June 14, 2010 08:24
-
-
Save xlson/437444 to your computer and use it in GitHub Desktop.
Script used to easily change grails version on the commandline in OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
/* setgrails: Script used to easily change grails version on the commandline in OS X | |
* | |
* My setup: | |
* /User/leo/Apps/grails Folder where all versions of grails are installed | |
* /User/leo/Apps/grails/grails A symlink pointing to the version of grails I'm currently using | |
* /User/leo/Apps/grails-1.3.1 One of the installed versions | |
* | |
* in ~/.profile | |
* export GRAILS_HOME=/User/leo/Apps/grails/grails | |
* export PATH=$GRAILS_HOME/bin:$PATH | |
*/ | |
// Validate args | |
assert args.size() == 1 | |
def version = args[0] | |
assert version ==~ /(?:\d+\.?)+/ | |
def grailsInstallDir = new File('/Users/leo/Apps/grails') | |
def currentGrails = new File(grailsInstallDir, 'grails') | |
def grailsHome = new File(grailsInstallDir, "grails-$version") | |
// Check that all needed folders exist | |
assert grailsInstallDir.exists() | |
assert currentGrails.exists() | |
assert grailsHome.exists() | |
// Remove old symlink and link to the choosen grails version | |
currentGrails.delete() | |
def proc = ['ln', '-s', grailsHome.absolutePath, currentGrails.absolutePath].execute() | |
proc.consumeProcessOutput System.out, System.err | |
println "GRAILS set to $version" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment