15
15
# See the License for the specific language governing permissions and
16
16
# limitations under the License.
17
17
#
18
+ # SPDX-License-Identifier: Apache-2.0
19
+ #
18
20
19
21
# #############################################################################
20
22
#
55
57
# Darwin, MinGW, and NonStop.
56
58
#
57
59
# (3) This script is generated from the Groovy template
58
- # https://github.com/gradle/gradle/blob/master/subprojects/ plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60
+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/ plugins-application /src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
61
# within the Gradle project.
60
62
#
61
63
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -69,90 +71,94 @@ app_path=$0
69
71
70
72
# Need this for daisy-chained symlinks.
71
73
while
72
- APP_HOME=${app_path% " ${app_path##*/ } " } # leaves a trailing /; empty if no leading path
73
- [ -h " ${ app_path} " ]
74
+ APP_HOME=${app_path% " ${app_path##*/ } " } # leaves a trailing /; empty if no leading path
75
+ [ -h " $app_path " ]
74
76
do
75
- ls=$( ls -ld " ${ app_path} " )
76
- link=${ls#* ' -> ' }
77
- case ${ link} in # (
78
- /* ) app_path=${ link} ;; # (
79
- * ) app_path=${ APP_HOME}${ link} ;;
80
- esac
77
+ ls=$( ls -ld " $app_path " )
78
+ link=${ls#* ' -> ' }
79
+ case $link in # (
80
+ /* ) app_path=$link ;; # (
81
+ * ) app_path=$APP_HOME$ link ;;
82
+ esac
81
83
done
82
84
83
- APP_HOME=$( cd " ${APP_HOME:- ./ } " && pwd -P) || exit
84
-
85
- APP_NAME=" Gradle"
85
+ # This is normally unused
86
+ # shellcheck disable=SC2034
86
87
APP_BASE_NAME=${0##*/ }
87
-
88
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
- DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
88
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89
+ APP_HOME=$( cd -P " ${APP_HOME:- ./ } " > /dev/null && printf ' %s\n' " $PWD " ) || exit
90
90
91
91
# Use the maximum available, or set MAX_FD != -1 to use that value.
92
92
MAX_FD=maximum
93
93
94
- warn () {
95
- echo " $* "
94
+ warn () {
95
+ echo " $* "
96
96
} >&2
97
97
98
- die () {
99
- echo
100
- echo " $* "
101
- echo
102
- exit 1
98
+ die () {
99
+ echo
100
+ echo " $* "
101
+ echo
102
+ exit 1
103
103
} >&2
104
104
105
105
# OS specific support (must be 'true' or 'false').
106
106
cygwin=false
107
107
msys=false
108
108
darwin=false
109
109
nonstop=false
110
- case " $( uname) " in # (
111
- CYGWIN* ) cygwin=true ;; # (
112
- Darwin* ) darwin=true ;; # (
113
- MSYS* | MINGW* ) msys=true ;; # (
114
- NONSTOP* ) nonstop=true ;;
110
+ case " $( uname ) " in # (
111
+ CYGWIN* ) cygwin=true ;; # (
112
+ Darwin* ) darwin=true ;; # (
113
+ MSYS* | MINGW* ) msys=true ;; # (
114
+ NONSTOP* ) nonstop=true ;;
115
115
esac
116
116
117
- CLASSPATH=${APP_HOME} /gradle/wrapper/gradle-wrapper.jar
117
+ CLASSPATH=$APP_HOME /gradle/wrapper/gradle-wrapper.jar
118
+
118
119
119
120
# Determine the Java command to use to start the JVM.
120
- if [ -n " ${ JAVA_HOME} " ]; then
121
- if [ -x " ${ JAVA_HOME} /jre/sh/java" ]; then
122
- # IBM's JDK on AIX uses strange locations for the executables
123
- JAVACMD=${ JAVA_HOME} /jre/sh/java
124
- else
125
- JAVACMD=${ JAVA_HOME} /bin/java
126
- fi
127
- if [ ! -x " ${ JAVACMD} " ]; then
128
- die " ERROR: JAVA_HOME is set to an invalid directory: ${ JAVA_HOME}
121
+ if [ -n " $JAVA_HOME " ] ; then
122
+ if [ -x " $JAVA_HOME /jre/sh/java" ] ; then
123
+ # IBM's JDK on AIX uses strange locations for the executables
124
+ JAVACMD=$JAVA_HOME /jre/sh/java
125
+ else
126
+ JAVACMD=$JAVA_HOME /bin/java
127
+ fi
128
+ if [ ! -x " $JAVACMD " ] ; then
129
+ die " ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
129
130
130
131
Please set the JAVA_HOME variable in your environment to match the
131
132
location of your Java installation."
132
- fi
133
+ fi
133
134
else
134
- JAVACMD=java
135
- which java > /dev/null 2>&1 || die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
135
+ JAVACMD=java
136
+ if ! command -v java > /dev/null 2>&1
137
+ then
138
+ die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
136
139
137
140
Please set the JAVA_HOME variable in your environment to match the
138
141
location of your Java installation."
142
+ fi
139
143
fi
140
144
141
145
# Increase the maximum file descriptors if we can.
142
- if ! " ${cygwin} " && ! " ${darwin} " && ! " ${nonstop} " ; then
143
- case ${MAX_FD} in # (
144
- max* )
145
- MAX_FD=$( ulimit -H -n) ||
146
- warn " Could not query maximum file descriptor limit"
147
- ;;
148
- esac
149
- case ${MAX_FD} in # (
150
- ' ' | soft) : ;; # (
151
- * )
152
- ulimit -n " ${MAX_FD} " ||
153
- warn " Could not set maximum file descriptor limit to ${MAX_FD} "
154
- ;;
155
- esac
146
+ if ! " $cygwin " && ! " $darwin " && ! " $nonstop " ; then
147
+ case $MAX_FD in # (
148
+ max* )
149
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150
+ # shellcheck disable=SC2039,SC3045
151
+ MAX_FD=$( ulimit -H -n ) ||
152
+ warn " Could not query maximum file descriptor limit"
153
+ esac
154
+ case $MAX_FD in # (
155
+ ' ' | soft) : ;; # (
156
+ * )
157
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158
+ # shellcheck disable=SC2039,SC3045
159
+ ulimit -n " $MAX_FD " ||
160
+ warn " Could not set maximum file descriptor limit to $MAX_FD "
161
+ esac
156
162
fi
157
163
158
164
# Collect all arguments for the java command, stacking in reverse order:
164
170
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
165
171
166
172
# For Cygwin or MSYS, switch paths to Windows format before running java
167
- if " ${cygwin} " || " ${msys} " ; then
168
- APP_HOME=$( cygpath --path --mixed " ${APP_HOME} " )
169
- CLASSPATH=$( cygpath --path --mixed " ${CLASSPATH} " )
170
-
171
- JAVACMD=$( cygpath --unix " ${JAVACMD} " )
172
-
173
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
174
- for arg; do
175
- if
176
- case ${arg} in # (
177
- -* ) false ;; # don't mess with options #(
178
- /?* )
179
- t=${arg#/ } t=/${t%%/* } # looks like a POSIX filepath
180
- [ -e " ${t} " ]
181
- ;; # (
182
- * ) false ;;
183
- esac
184
- then
185
- arg=$( cygpath --path --ignore --mixed " ${arg} " )
186
- fi
187
- # Roll the args list around exactly as many times as the number of
188
- # args, so each arg winds up back in the position where it started, but
189
- # possibly modified.
190
- #
191
- # NB: a `for` loop captures its iteration list before it begins, so
192
- # changing the positional parameters here affects neither the number of
193
- # iterations, nor the values presented in `arg`.
194
- shift # remove old arg
195
- set -- " $@ " " ${arg} " # push replacement arg
196
- done
173
+ if " $cygwin " || " $msys " ; then
174
+ APP_HOME=$( cygpath --path --mixed " $APP_HOME " )
175
+ CLASSPATH=$( cygpath --path --mixed " $CLASSPATH " )
176
+
177
+ JAVACMD=$( cygpath --unix " $JAVACMD " )
178
+
179
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
180
+ for arg do
181
+ if
182
+ case $arg in # (
183
+ -* ) false ;; # don't mess with options #(
184
+ /?* ) t=${arg#/ } t=/${t%%/* } # looks like a POSIX filepath
185
+ [ -e " $t " ] ;; # (
186
+ * ) false ;;
187
+ esac
188
+ then
189
+ arg=$( cygpath --path --ignore --mixed " $arg " )
190
+ fi
191
+ # Roll the args list around exactly as many times as the number of
192
+ # args, so each arg winds up back in the position where it started, but
193
+ # possibly modified.
194
+ #
195
+ # NB: a `for` loop captures its iteration list before it begins, so
196
+ # changing the positional parameters here affects neither the number of
197
+ # iterations, nor the values presented in `arg`.
198
+ shift # remove old arg
199
+ set -- " $@ " " $arg " # push replacement arg
200
+ done
197
201
fi
198
202
199
- # Collect all arguments for the java command;
200
- # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
201
- # shell script including quotes and variable substitutions, so put them in
202
- # double quotes to make sure that they get re-expanded; and
203
- # * put everything else in single quotes, so that it's not re-expanded.
203
+
204
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205
+ DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
206
+
207
+ # Collect all arguments for the java command:
208
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209
+ # and any embedded shellness will be escaped.
210
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211
+ # treated as '${Hostname}' itself on the command line.
204
212
205
213
set -- \
206
- " -Dorg.gradle.appname=${APP_BASE_NAME} " \
207
- -classpath " ${CLASSPATH} " \
208
- org.gradle.wrapper.GradleWrapperMain \
209
- " $@ "
214
+ " -Dorg.gradle.appname=$APP_BASE_NAME " \
215
+ -classpath " $CLASSPATH " \
216
+ org.gradle.wrapper.GradleWrapperMain \
217
+ " $@ "
218
+
219
+ # Stop when "xargs" is not available.
220
+ if ! command -v xargs > /dev/null 2>&1
221
+ then
222
+ die " xargs is not available"
223
+ fi
210
224
211
225
# Use "xargs" to parse quoted args.
212
226
#
@@ -228,10 +242,10 @@ set -- \
228
242
#
229
243
230
244
eval " set -- $(
231
- printf ' %s\n' " ${ DEFAULT_JVM_OPTS} ${ JAVA_OPTS} ${ GRADLE_OPTS} " |
232
- xargs -n1 |
233
- sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
234
- tr ' \n' ' '
235
- ) " ' "$@"'
245
+ printf ' %s\n' " $DEFAULT_JVM_OPTS $ JAVA_OPTS $ GRADLE_OPTS" |
246
+ xargs -n1 |
247
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248
+ tr ' \n' ' '
249
+ ) " ' "$@"'
236
250
237
- exec " ${ JAVACMD} " " $@ "
251
+ exec " $JAVACMD " " $@ "
0 commit comments