gradle: adopt `_bash_it_find_in_ancestor()`

pull/1952/head
John D Pell 2021-09-22 15:29:47 -07:00
parent 0471a20c7c
commit 7ed12083f2
2 changed files with 6 additions and 23 deletions

View File

@ -22,17 +22,9 @@
# Avoid inaccurate completions for subproject tasks # Avoid inaccurate completions for subproject tasks
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g') COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
__gradle-set-project-root-dir() { function __gradle-set-project-root-dir() {
local dir="${PWD}" project_root_dir="$(_bash-it-find-in-ancestor "settings.gradle" "gradlew")"
project_root_dir="${PWD}" return "$?"
while [[ $dir != '/' ]]; do
if [[ -f "$dir/settings.gradle" || -f "$dir/gradlew" ]]; then
project_root_dir=$dir
return 0
fi
dir="$(dirname "$dir")"
done
return 1
} }
__gradle-init-cache-dir() { __gradle-init-cache-dir() {

View File

@ -3,19 +3,10 @@ about-plugin 'Add a gw command to use gradle wrapper if present, else use system
function gw() { function gw() {
local file="gradlew" local file="gradlew"
local curr_path="${PWD}" local result
local result="gradle"
# Search recursively upwards for file. result="$(_bash-it-find-in-ancestor "${file}")"
until [[ "${curr_path}" == "/" ]]; do
if [[ -e "${curr_path}/${file}" ]]; then
result="${curr_path}/${file}"
break
else
curr_path=$(dirname "${curr_path}")
fi
done
# Call gradle # Call gradle
"${result}" $* "${result:-gradle}" $*
} }