-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmw
executable file
·50 lines (45 loc) · 1.18 KB
/
gmw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# Is the project directory in HOME?
if [ "${PWD#"$HOME/"}" = "$PWD" ]
then
SEARCH_ENDPOINT="/"
else
SEARCH_ENDPOINT="$HOME"
fi
locate_parent_directory_with_root_markers() {
search_dir="$PWD"
while [ "$search_dir" != "$SEARCH_ENDPOINT" ]
do
for marker
do
if [ -e "$search_dir/$marker" ]
then
printf '%s' "$search_dir"
return
fi
done
search_dir="$(dirname "$search_dir")"
done
printf "%s" ""
}
root_project="$(locate_parent_directory_with_root_markers 'settings.gradle' 'settings.gradle.kts')"
if [ ! "$root_project" ]
then
# No settings file.
# Can't rule out the possibility of single-project build
# Since settings file is optional for such builds
# In which case, must check for a build script
root_project="$(locate_parent_directory_with_root_markers 'build.gradle' 'build.gradle.kts')"
fi
if [ "$root_project" ]
then
cd "$root_project" || exit
if [ -e "gradlew" ]
then
./gradlew "$@"
else
echo "The gradle wrapper script doesn't exist. Run 'gradle init' first."
fi
else
echo "Not a gradle project."
fi