Skip to content

Instantly share code, notes, and snippets.

@franzbecker
Last active March 27, 2016 13:44
Show Gist options
  • Save franzbecker/b4bb77f66d36472548bf to your computer and use it in GitHub Desktop.
Save franzbecker/b4bb77f66d36472548bf to your computer and use it in GitHub Desktop.
Bash function for using ./gradlew or gradle as fall-back
# Call ./gradlew or gradle as fall-back
function g() {
if [ -f gradlew ]; then
./gradlew $@
else
# if there is no ./gradlew check if there is a build.gradle file
# if not ask the user for confirmation (avoid creation of .gradle dir in unrelated directories)
if [ -f build.gradle ]; then
gradle $@
else
read -n1 -p "There is no build.gradle in this directory. Do you want to continue? [y,n]" doit
echo ""
case $doit in
y|Y) gradle $@ ;;
esac
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment