-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-gradle.sh
executable file
·79 lines (74 loc) · 2.18 KB
/
run-gradle.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# PURPOSE
#
# The Gradle wrapper[1] is a simple and convenient way of making Gradle
# builds self-contained and reproducible. However, in multi-project
# builds, it can be cumbersome to type in relative paths e.g.:
# ./gradlew # when in root
# ../gradlew # when in subdir
#
# This script finds any Gradle wrapper (gradlew) executable in the
# current directory or any directory above it. If none can be found,
# it will fall back to the system-wide installation at $SYSTEM_GRADLE.
#
#
# INSTALLATION
#
# 1. Remove GRADLE_HOME/bin from your PATH if it's already present.
#
# $ which gradle # should return empty when finished
#
# 2. Symlink find-gradle somewhere on your path as 'gradle', e.g.:
#
# $ ln -s $PWD/find-gradle /usr/local/bin/gradle
#
#
# USAGE
#
# Use exactly like you would a normal Gradle executable. All arguments
# supplied are `exec`d against the gradle(w) executable once found.
#
# $ gradle [options]
#
#
# DEBUGGING
#
# To observe the search for gradlew and to ensure which one is
# ultimately used, invoke the script with Bash's "-x" option. Below you
# can see the directory traversal at work, finally selecting the
# 'gradlew' script one directory up from where 'gradle' was invoked.
#
# $ cd /Work/spring-framework/spring-context
# $ bash -x $(which gradle) --version
# + GRADLEW=/Work/spring-framework/spring-context/gradlew
# + GRADLEW=/Work/spring-framework/gradlew
# + /Work/spring-framework/gradlew --version
#
# ------------------------------------------------------------
# Gradle 1.0-milestone-8-20120112000036+0100
# ------------------------------------------------------------
# ...
#
#
# AUTHOR
#
# Chris Beams (http://twitter.com/cbeams)
#
#
# BUGS
#
# It doesn't look for 'gradlew' in the root directory. Why would you
# want it to? Improvements welcome at http://github.com/cbeams/shell-scripts.
#
# [1] http://gradle.org/docs/current/userguide/gradle_wrapper.html
SYSTEM_GRADLE=/usr/local/bin/gradle
CWD=$PWD
until [ $CWD == / ]; do
GRADLEW=$CWD/gradlew
if [ -e $GRADLEW ]; then
exec $GRADLEW $@
fi
CWD=$(dirname $CWD)
done
echo No Gradle wrapper found, using $SYSTEM_GRADLE
exec $SYSTEM_GRADLE "$@"