Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2 from mattdelliott/master

Support for pulling in missing grails sdks
  • Loading branch information...
commit 5ed70f989aa7704acfa46e6189aa00c9078595cb 2 parents f272e62 + e36fd40
@deluan authored
Showing with 25 additions and 6 deletions.
  1. +7 −4 README.md
  2. +18 −2 grails
View
11 README.md
@@ -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
------------
@@ -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
View
20 grails
@@ -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
@@ -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
@@ -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

0 comments on commit 5ed70f9

Please sign in to comment.
Something went wrong with that request. Please try again.