11#! /bin/sh
2+
23#
34# Copyright © 2015-2021 the original authors.
45#
1415# See the License for the specific language governing permissions and
1516# limitations under the License.
1617#
18+
1719# #############################################################################
1820#
1921# Gradle start up script for POSIX generated by Gradle.
2426# noncompliant, but you have some other compliant shell such as ksh or
2527# bash, then to run this script, type that shell name before the whole
2628# command line, like:
27-
28-
29-
30-
31-
32-
33-
34- Expand Down
35-
36-
37-
38-
39-
40- Expand Up
41-
42- @@ -85,7 +85,7 @@ done
43-
4429#
4530# ksh Gradle
4631#
7661# You can find Gradle at https://github.com/gradle/gradle/.
7762#
7863# #############################################################################
64+
7965# Attempt to set APP_HOME
66+
8067# Resolve links: $0 may be a link
8168app_path=$0
69+
8270# Need this for daisy-chained symlinks.
8371while
8472 APP_HOME=${app_path% " ${app_path##*/ } " } # leaves a trailing /; empty if no leading path
9179 * ) app_path=$APP_HOME$link ;;
9280 esac
9381done
82+
9483# This is normally unused
9584# shellcheck disable=SC2034
9685APP_BASE_NAME=${0##*/ }
@@ -100,27 +89,19 @@ APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
10089DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
10190
10291# Use the maximum available, or set MAX_FD != -1 to use that value.
103-
104-
105-
106-
107-
108-
109-
110- Expand Down
111-
112-
113-
11492MAX_FD=maximum
93+
11594warn () {
11695 echo " $* "
11796} >&2
97+
11898die () {
11999 echo
120100 echo " $* "
121101 echo
122102 exit 1
123103} >&2
104+
124105# OS specific support (must be 'true' or 'false').
125106cygwin=false
126107msys=false
@@ -132,7 +113,10 @@ case "$( uname )" in #(
132113 MSYS* | MINGW* ) msys=true ;; # (
133114 NONSTOP* ) nonstop=true ;;
134115esac
116+
135117CLASSPATH=$APP_HOME /gradle/wrapper/gradle-wrapper.jar
118+
119+
136120# Determine the Java command to use to start the JVM.
137121if [ -n " $JAVA_HOME " ] ; then
138122 if [ -x " $JAVA_HOME /jre/sh/java" ] ; then
@@ -143,15 +127,18 @@ if [ -n "$JAVA_HOME" ] ; then
143127 fi
144128 if [ ! -x " $JAVACMD " ] ; then
145129 die " ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130+
146131Please set the JAVA_HOME variable in your environment to match the
147132location of your Java installation."
148133 fi
149134else
150135 JAVACMD=java
151136 which java > /dev/null 2>&1 || die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137+
152138Please set the JAVA_HOME variable in your environment to match the
153139location of your Java installation."
154140fi
141+
155142# Increase the maximum file descriptors if we can.
156143if ! " $cygwin " && ! " $darwin " && ! " $nonstop " ; then
157144 case $MAX_FD in # (
@@ -170,18 +157,22 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
170157 warn " Could not set maximum file descriptor limit to $MAX_FD "
171158 esac
172159fi
160+
173161# Collect all arguments for the java command, stacking in reverse order:
174162# * args from the command line
175163# * the main class name
176164# * -classpath
177165# * -D...appname settings
178166# * --module-path (only if needed)
179167# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
168+
180169# For Cygwin or MSYS, switch paths to Windows format before running java
181170if " $cygwin " || " $msys " ; then
182171 APP_HOME=$( cygpath --path --mixed " $APP_HOME " )
183172 CLASSPATH=$( cygpath --path --mixed " $CLASSPATH " )
173+
184174 JAVACMD=$( cygpath --unix " $JAVACMD " )
175+
185176 # Now convert the arguments - kludge to limit ourselves to /bin/sh
186177 for arg do
187178 if
@@ -205,21 +196,25 @@ if "$cygwin" || "$msys" ; then
205196 set -- " $@ " " $arg " # push replacement arg
206197 done
207198fi
199+
208200# Collect all arguments for the java command;
209201# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
210202# shell script including quotes and variable substitutions, so put them in
211203# double quotes to make sure that they get re-expanded; and
212204# * put everything else in single quotes, so that it's not re-expanded.
205+
213206set -- \
214207 " -Dorg.gradle.appname=$APP_BASE_NAME " \
215208 -classpath " $CLASSPATH " \
216209 org.gradle.wrapper.GradleWrapperMain \
217210 " $@ "
211+
218212# Stop when "xargs" is not available.
219213if ! command -v xargs > /dev/null 2>&1
220214then
221215 die " xargs is not available"
222216fi
217+
223218# Use "xargs" to parse quoted args.
224219#
225220# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
238233# This will of course break if any of these variables contains a newline or
239234# an unmatched quote.
240235#
236+
241237eval " set -- $(
242238 printf ' %s\n' " $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS " |
243239 xargs -n1 |
244240 sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
245241 tr ' \n' ' '
246242 ) " ' "$@"'
243+
247244exec " $JAVACMD " " $@ "
0 commit comments