1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-03-30 19:23:56 +08:00
ohmyzsh-mirror/plugins/gradle/gradle.plugin.zsh
G'lek Tarssza 32b1498c1b
feat(gradle): Aliased to gradlew as well as gradle.
Added this change to the `README.md`.

Also cleaned/reworded up the `README.md` a touch.
2026-03-12 07:49:40 -06:00

28 lines
787 B
Bash

# Looks for a gradlew file in the current working directory
# or any of its parent directories, and executes it if found.
# Otherwise it will call gradle directly.
function gradle-or-gradlew() {
# find project root
# taken from https://github.com/gradle/gradle-completion
local dir="$PWD" project_root="$PWD"
while [[ "$dir" != / ]]; do
if [[ -x "$dir/gradlew" ]]; then
project_root="$dir"
break
fi
dir="${dir:h}"
done
# if local gradle wrapper found, run it instead of gradle
if [[ -f "$project_root/gradlew" ]]; then
echo "executing local gradle wrapper instead of gradle"
"$project_root/gradlew" "$@"
else
command gradle "$@"
fi
}
alias gradle=gradle-or-gradlew
alias gradlew=gradle-or-gradlew
compdef _gradle gradle-or-gradlew