Skip to content

Instantly share code, notes, and snippets.

@ae6rt
Last active December 21, 2015 01:28
Show Gist options
  • Save ae6rt/6227681 to your computer and use it in GitHub Desktop.
Save ae6rt/6227681 to your computer and use it in GitHub Desktop.
A shell script which searches the current working directory and upward for Gradle gradlew wrapper script. Place the file on your path and make it executable.
#!/bin/bash
set -u
FOUND=0
CURR_PATH="$PWD"
REAL_GRADLEW="$CURR_PATH/gradlew"
if [ -x "$REAL_GRADLEW" ]
then
FOUND=1
else
while [ "$CURR_PATH" != "/" ]
do
CURR_PATH=$(dirname "$CURR_PATH")
REAL_GRADLEW="$CURR_PATH/gradlew"
if [ -x "$REAL_GRADLEW" ]
then
FOUND=1
break
fi
done
fi
if [ $FOUND -eq 1 ]
then
$REAL_GRADLEW "$@"
else
echo "Unable to find gradlew file upwards in filesystem"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment