Grails version auto-detection
I've implemented a little helper script that helps being more productive when working with multiple Grails versions. If the current working directory is a grails application, the scripts detects the version (via application.properties), sets the GRAILS_HOME environment variable and executes the appropriate Grails executable.
#!/bin/bash
GRAILS_BASE=/opt/grails
DEFAULT_VERSION="1.0.4"
ARGS=$@
EXECUTABLE="grails"
if [ -f application.properties ]; then
GRAILS_VERSION=$( cat application.properties | grep "app.grails.version=" | sed -e "s/^.*=//" | tr -d '\r\n ' )
echo "Detected Grails $GRAILS_VERSION"
else
echo "Using default Grails $DEFAULT_VERSION"
GRAILS_VERSION=$DEFAULT_VERSION
fi
GRAILS_VERSION_DIR="$GRAILS_BASE/grails-$GRAILS_VERSION"
if [ ! -d $GRAILS_VERSION_DIR ]; then
echo "Grails Version $GRAILS_VERSION is not installed! ($GRAILS_BASE/grails-$GRAILS_VERSION)"
exit 1
fi
export GRAILS_HOME=$GRAILS_VERSION_DIR
$GRAILS_VERSION_DIR/bin/$EXECUTABLE $ARGS
Labels: Grails






Loading ...