Skip to content

Commit

Permalink
Merge pull request #2 from mattdelliott/master
Browse files Browse the repository at this point in the history
Support for pulling in missing grails sdks
  • Loading branch information
deluan committed May 17, 2012
2 parents f272e62 + e36fd40 commit 5ed70f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Prerequisites
/opt/grails-1.3.2

* `GRAILS_HOME` environment variable must be set and point to your "default" Grails installation
* This script was tested on Mac OS X (Snow Leopard), Linux (Ubuntu) and Windows (with cygwin)
* cURL and unzip (If you want it to automatically pull missing versions)
* This script was tested on Mac OS X (Lion), Linux (Ubuntu) and Windows (with cygwin)

Installation
------------
Expand All @@ -22,9 +23,11 @@ Usage

Using the script is as transparent as possible:

* If you invoke it from a project folder, it will detect the version used by the project and call the correct grails (if it is installed in your system)
* If you invoke it from a project folder, it will detect the version used by the project and call the correct grails
* If the required version does not exist locally, the script will attempt to download the version specified from grails amazon mirror
* If you invoke it from any other folder that does not contain a Grails project, it will call the "default" Grails installation
* If you want to call a specific Grails version (i.e. when doing an upgrade) you can specify the version you want in the first parameter. Ex:
* If you want to call a specific Grails version (i.e. when doing an upgrade) you can specify the version you want in the first parameter.
* If the version you specified does not exist locally, it will also attempt to download the version specified.

$ grails 1.3.3 upgrade
Ex: $ grails 1.3.3 upgrade

20 changes: 18 additions & 2 deletions grails
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
# Author: Deluan (http://github.com/deluan)
# Original Author: Deluan (http://github.com/deluan)
# Updated By: mattdelliott (http://github.com/mattdelliott)

# Check if GRAILS_HOME is set
if [ -z "$GRAILS_HOME" -o ! -d "$GRAILS_HOME" ]; then
Expand All @@ -20,7 +21,7 @@ APP_PROP="application.properties"

# Try to get the version from the command line
TRY_VERSION=$1
if [ -d "${BASE_GRAILS_PATH}/grails-${TRY_VERSION}" ]; then
if [[ $TRY_VERSION =~ [0-9]\.[0-9]\.[0-9] ]]; then
VERSION=$TRY_VERSION
shift
fi
Expand All @@ -34,6 +35,21 @@ fi
VERSION=$DEFAULT_VERSION

export GRAILS_HOME=${BASE_GRAILS_PATH}/grails-${VERSION}

# Attempt to download and unzip the specified version if it does not exist
if [ ! -d ${GRAILS_HOME} ]; then
NEW_GRAILS_FILE=grails-${VERSION}
echo "grails ${VERSION} does not exist, attempting to download..."
curl "http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/${NEW_GRAILS_FILE}.zip" -o ${NEW_GRAILS_FILE}.zip
unzip ./${NEW_GRAILS_FILE}.zip -d ${BASE_GRAILS_PATH}/
rm -rf ${NEW_GRAILS_FILE}.zip
if [ -d ${GRAILS_HOME} ]; then
echo "Got grails version $VERSION successfully"
else
echo "Failed to get grails version $VERSION"
fi
fi

GRAILS_CMD=${GRAILS_HOME}/bin/grails

if [ ! -x "$GRAILS_CMD" ]; then
Expand Down

0 comments on commit 5ed70f9

Please sign in to comment.