Skip to content

Instantly share code, notes, and snippets.

@kanemu
Last active December 10, 2015 03:18
Show Gist options
  • Save kanemu/4373840 to your computer and use it in GitHub Desktop.
Save kanemu/4373840 to your computer and use it in GitHub Desktop.
# usage:
# This script must be placed in the ~/.gvm/ext folder
function gvm_glstart {
ARGS=$@
EXECUTABLE="grails"
if [ -f application.properties ]; then
G_VERSION=$( cat application.properties | grep "app.grails.version=" | sed -e "s/^.*=//" | tr -d '\r\n ' )
echo "Detected Grails ${G_VERSION}"
else
echo "Using current Grails version."
G_VERSION="current"
fi
G_VERSION_DIR="${GVM_DIR}/grails/${G_VERSION}"
if [ ! -d ${G_VERSION_DIR} ]; then
echo "Grails Version ${G_VERSION} is not installed. (${GVM_DIR}/grails/${G_VERSION})"
echo -n "Do you want to install it now? (Y/n): "
read INSTALL
if [[ -z "${INSTALL}" || "${INSTALL}" == "y" || "${INSTALL}" == "Y" ]]; then
__gvmtool_install_candidate_version "${EXECUTABLE}" "${G_VERSION}"
if [ ! -d "${GVM_DIR}/grails/current" ]; then
echo -n "Do you want to use ${EXECUTABLE} ${G_VERSION} now? (Y/n): "
read USE
if [[ -z "${USE}" || "${USE}" == "y" || "${USE}" == "Y" ]]; then
__gvmtool_link_candidate_version "${EXECUTABLE}" "${G_VERSION}"
echo ""
echo Using "${EXECUTABLE}" version "${G_VERSION}"
fi
fi
else
return 1
fi
fi
GRAILS_HOME=${G_VERSION_DIR}
${GRAILS_HOME}/bin/${EXECUTABLE} ${ARGS}
GRAILS_HOME="${GVM_DIR}/grails/current"
}
alias grails="gvm_glstart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment