Created
May 27, 2015 07:42
-
-
Save tehlers/3a9944ff751a17280732 to your computer and use it in GitHub Desktop.
This script will execute the Gradle wrapper, if it is available in the current or a parent directory. Otherwise it will fall back to start the Gradle version found in $PATH. The intended way to use this script is as an alias for 'gradle'.
This file contains hidden or 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 bash | |
# | |
# This script will execute the Gradle wrapper, if it is available in the current | |
# or a parent directory. Otherwise it will fall back to start the Gradle version | |
# found in $PATH. | |
# | |
# The intended way to use this script is as an alias for 'gradle'. | |
# | |
WORK_DIR=$(pwd) | |
while [[ $PWD != / ]]; do | |
WRAPPER=$(find "$PWD"/ -maxdepth 1 -name "gradlew") | |
if [ -n "$WRAPPER" ]; then | |
break | |
fi | |
cd .. | |
done | |
cd "$WORK_DIR" | |
if [ -n "$WRAPPER" ]; then | |
$WRAPPER "$@" | |
else | |
gradle "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment