1 # Looks for a gradlew file in the current working directory
2 # or any of its parent directories, and executes it if found.
3 # Otherwise it will call gradle directly.
4 function gradle-or-gradlew() {
6 # taken from https://github.com/gradle/gradle-completion
7 local dir="$PWD" project_root="$PWD"
8 while [[ "$dir" != / ]]; do
9 if [[ -f "$dir/settings.gradle" || -f "$dir/settings.gradle.kts" || -f "$dir/gradlew" ]]; then
16 # if gradlew found, run it instead of gradle
17 if [[ -f "$project_root/gradlew" ]]; then
18 echo "executing gradlew instead of gradle"
19 "$project_root/gradlew" "$@"
25 alias gradle=gradle-or-gradlew
26 compdef _gradle gradle-or-gradlew