11#! /bin/sh
22
33#
4- # Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
4+ # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
55#
66
77# #############################################################################
4343# Darwin, MinGW, and NonStop.
4444#
4545# (3) This script is generated from the Groovy template
46- # https://github.com/gradle/gradle/blob/master/subprojects/ plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
46+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/ plugins-application /src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
4747# within the Gradle project.
4848#
4949# You can find Gradle at https://github.com/gradle/gradle/.
6868 esac
6969done
7070
71- APP_HOME=$( cd " ${APP_HOME:- ./ } " && pwd -P ) || exit
72-
73- APP_NAME=" Gradle"
71+ # This is normally unused
72+ # shellcheck disable=SC2034
7473APP_BASE_NAME=${0##*/ }
75-
76- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
77- DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
74+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
75+ APP_HOME=$( cd -P " ${APP_HOME:- ./ } " > /dev/null && printf ' %s\n' " $PWD " ) || exit
7876
7977# Use the maximum available, or set MAX_FD != -1 to use that value.
8078MAX_FD=maximum
@@ -102,7 +100,7 @@ case "$( uname )" in #(
102100 NONSTOP* ) nonstop=true ;;
103101esac
104102
105- CLASSPATH=$APP_HOME /gradle/wrapper/gradle-wrapper.jar
103+ CLASSPATH=" \\\"\\\" "
106104
107105
108106# Determine the Java command to use to start the JVM.
@@ -121,22 +119,29 @@ location of your Java installation."
121119 fi
122120else
123121 JAVACMD=java
124- which java > /dev/null 2>&1 || die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
122+ if ! command -v java > /dev/null 2>&1
123+ then
124+ die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
125125
126126Please set the JAVA_HOME variable in your environment to match the
127127location of your Java installation."
128+ fi
128129fi
129130
130131# Increase the maximum file descriptors if we can.
131132if ! " $cygwin " && ! " $darwin " && ! " $nonstop " ; then
132133 case $MAX_FD in # (
133134 max* )
135+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
136+ # shellcheck disable=SC2039,SC3045
134137 MAX_FD=$( ulimit -H -n ) ||
135138 warn " Could not query maximum file descriptor limit"
136139 esac
137140 case $MAX_FD in # (
138141 ' ' | soft) : ;; # (
139142 * )
143+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
144+ # shellcheck disable=SC2039,SC3045
140145 ulimit -n " $MAX_FD " ||
141146 warn " Could not set maximum file descriptor limit to $MAX_FD "
142147 esac
@@ -181,18 +186,28 @@ if "$cygwin" || "$msys" ; then
181186 done
182187fi
183188
184- # Collect all arguments for the java command;
185- # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
186- # shell script including quotes and variable substitutions, so put them in
187- # double quotes to make sure that they get re-expanded; and
188- # * put everything else in single quotes, so that it's not re-expanded.
189+
190+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
191+ DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
192+
193+ # Collect all arguments for the java command:
194+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
195+ # and any embedded shellness will be escaped.
196+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
197+ # treated as '${Hostname}' itself on the command line.
189198
190199set -- \
191200 " -Dorg.gradle.appname=$APP_BASE_NAME " \
192201 -classpath " $CLASSPATH " \
193- org. gradle. wrapper.GradleWrapperMain \
202+ -jar " $APP_HOME / gradle/ wrapper/gradle-wrapper.jar " \
194203 " $@ "
195204
205+ # Stop when "xargs" is not available.
206+ if ! command -v xargs > /dev/null 2>&1
207+ then
208+ die " xargs is not available"
209+ fi
210+
196211# Use "xargs" to parse quoted args.
197212#
198213# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
0 commit comments