Skip to content

Commit 4ab0089

Browse files
committed
gradle: adopt _bash_it_find_kin()
1 parent 7b6caac commit 4ab0089

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

completion/available/gradle.completion.bash

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,9 @@
2222
# Avoid inaccurate completions for subproject tasks
2323
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
2424

25-
__gradle-set-project-root-dir() {
26-
local dir="${PWD}"
27-
project_root_dir="${PWD}"
28-
while [[ $dir != '/' ]]; do
29-
if [[ -f "$dir/settings.gradle" || -f "$dir/gradlew" ]]; then
30-
project_root_dir=$dir
31-
return 0
32-
fi
33-
dir="$(dirname "$dir")"
34-
done
35-
return 1
25+
function __gradle-set-project-root-dir() {
26+
project_root_dir="$(_find_uncle "settings.gradle" "gradlew")"
27+
return "$?"
3628
}
3729

3830
__gradle-init-cache-dir() {

plugins/available/gradle.plugin.bash

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@ about-plugin 'Add a gw command to use gradle wrapper if present, else use system
33

44
function gw() {
55
local file="gradlew"
6-
local curr_path="${PWD}"
7-
local result="gradle"
6+
local result
87

9-
# Search recursively upwards for file.
10-
until [[ "${curr_path}" == "/" ]]; do
11-
if [[ -e "${curr_path}/${file}" ]]; then
12-
result="${curr_path}/${file}"
13-
break
14-
else
15-
curr_path=$(dirname "${curr_path}")
16-
fi
17-
done
8+
result="$(_find_uncle "${file}")"
189

1910
# Call gradle
20-
"${result}" $*
11+
"${result:-gradle}" $*
2112
}

0 commit comments

Comments
 (0)