Skip to content

Commit a338bf2

Browse files
committed
KAFKA-19591 solving issues with gradlew content: an old template version (i.e. file unixStartScript.txt was being referenced)
1 parent 8deb6c6 commit a338bf2

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

gradlew

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/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
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -112,20 +114,7 @@ case "$( uname )" in #(
112114
NONSTOP* ) nonstop=true ;;
113115
esac
114116

115-
116-
# Loop in case we encounter an error.
117-
for attempt in 1 2 3; do
118-
if [ ! -e "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" ]; then
119-
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v8.14.1/gradle/wrapper/gradle-wrapper.jar"; then
120-
rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
121-
# Pause for a bit before looping in case the server throttled us.
122-
sleep 5
123-
continue
124-
fi
125-
fi
126-
done
127-
128-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
129118

130119

131120
# Determine the Java command to use to start the JVM.
@@ -212,19 +201,32 @@ if "$cygwin" || "$msys" ; then
212201
fi
213202

214203

204+
205+
# Loop in case we encounter an error.
206+
for attempt in 1 2 3; do
207+
if [ ! -e "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" ]; then
208+
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v8.14.1/gradle/wrapper/gradle-wrapper.jar"; then
209+
rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
210+
# Pause for a bit before looping in case the server throttled us.
211+
sleep 5
212+
continue
213+
fi
214+
fi
215+
done
216+
215217
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
216218
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
217219

218220
# Collect all arguments for the java command:
219-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
221+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
220222
# and any embedded shellness will be escaped.
221223
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
222224
# treated as '${Hostname}' itself on the command line.
223225

224226
set -- \
225227
"-Dorg.gradle.appname=$APP_BASE_NAME" \
226228
-classpath "$CLASSPATH" \
227-
org.gradle.wrapper.GradleWrapperMain \
229+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
228230
"$@"
229231

230232
# Stop when "xargs" is not available.

wrapper.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ task bootstrapWrapper() {
5959
done
6060
""".stripIndent()
6161

62+
String putBootstrapStringAbove = "# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script."
63+
6264
def wrapperScript = wrapper.scriptFile
6365
def wrapperLines = wrapperScript.readLines()
6466
wrapperScript.withPrintWriter { out ->
6567
def bootstrapWritten = false
6668
wrapperLines.each { line ->
6769
// Print the wrapper bootstrap before the first usage of the wrapper jar.
68-
if (!bootstrapWritten && line.contains("gradle-wrapper.jar")) {
70+
if (!bootstrapWritten && line.contains(putBootstrapStringAbove)) {
6971
out.println(bootstrapString)
7072
bootstrapWritten = true
7173
}

0 commit comments

Comments
 (0)