Skip to content

Instantly share code, notes, and snippets.

@breskeby
Created July 2, 2013 21:08
Show Gist options
  • Save breskeby/5913145 to your computer and use it in GitHub Desktop.
Save breskeby/5913145 to your computer and use it in GitHub Desktop.
#!/bin/bash
FOUND=0
CURR_PATH="$PWD"
REAL_GRADLEW="$CURR_PATH/gradlew"
REAL_MASTER_GRADLEW="$CURR_PATH/master/gradlew"
# Check current directory, which might be root directory for gradlew
if [ -x "$REAL_GRADLEW" ]; then
FOUND=1
elif [ -x "$REAL_MASTER_GRADLEW" ]; then
FOUND=2
else
while [ "$CURR_PATH" != "/" ]; do
CURR_PATH=$(dirname "$CURR_PATH")
REAL_GRADLEW="$CURR_PATH/gradlew"
if [ -x "$REAL_GRADLEW" ]; then
FOUND=1
break
fi
REAL_MASTER_GRADLEW="$CURR_PATH/master/gradlew"
if [ -x "$REAL_MASTER_GRADLEW" ]; then
FOUND=2
break
fi
done
fi
if [ $FOUND -eq 1 ]; then
"$REAL_GRADLEW" "$@"
elif [ $FOUND -eq 2 ]; then
"$REAL_MASTER_GRADLEW" "$@"
else
echo "Unable to find gradlew file upwards in filesystem"
fi
exit 0
@breskeby
Copy link
Author

breskeby commented Jul 2, 2013

This is a custom gradlew script, that you can put on your bash path. It delegates to the gradlew script in the root project folder. It allows you to run a gradle build from a subdirectory using the wrapper. I havn't created this one on my own, but don't remember anymore where I found it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment