From 461e8e369b5a695a687bea169127a600b798c4bc Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Wed, 8 Oct 2025 14:47:08 +0800 Subject: [PATCH 01/12] revert JVM options and CLASSPATH --- gradlew | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gradlew b/gradlew index 98a05d787ee04..e9ec4c1024da1 100755 --- a/gradlew +++ b/gradlew @@ -115,6 +115,8 @@ case "$( uname )" in #( esac +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then @@ -171,6 +173,7 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -220,10 +223,13 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. - +# +# Before gradle 8.14 were not support using an executable JAR for the wrapper. +# It causes a no main manifest attribute error if developers use the old wrapper. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ "$@" # Stop when "xargs" is not available. From c0b0428457b6b9574a4e78c3845d4a4a264ab649 Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Wed, 8 Oct 2025 15:03:08 +0800 Subject: [PATCH 02/12] revise comments --- gradlew | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradlew b/gradlew index e9ec4c1024da1..18cd53e65fb3e 100755 --- a/gradlew +++ b/gradlew @@ -224,7 +224,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. # -# Before gradle 8.14 were not support using an executable JAR for the wrapper. +# Before gradle 8.14 didn't support using an executable JAR for the wrapper. # It causes a no main manifest attribute error if developers use the old wrapper. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ From 002b8ca515672eeb08ac7fe7eca5bf7825dd130d Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Fri, 10 Oct 2025 15:35:40 +0800 Subject: [PATCH 03/12] Revert "revise comments" This reverts commit c0b0428457b6b9574a4e78c3845d4a4a264ab649. --- gradlew | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradlew b/gradlew index 18cd53e65fb3e..e9ec4c1024da1 100755 --- a/gradlew +++ b/gradlew @@ -224,7 +224,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. # -# Before gradle 8.14 didn't support using an executable JAR for the wrapper. +# Before gradle 8.14 were not support using an executable JAR for the wrapper. # It causes a no main manifest attribute error if developers use the old wrapper. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ From 199f8f9c9acde4c7bfb04642ca40f6183e9d3a77 Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Fri, 10 Oct 2025 15:35:54 +0800 Subject: [PATCH 04/12] Revert "revert JVM options and CLASSPATH" This reverts commit 461e8e369b5a695a687bea169127a600b798c4bc. --- gradlew | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/gradlew b/gradlew index e9ec4c1024da1..98a05d787ee04 100755 --- a/gradlew +++ b/gradlew @@ -115,8 +115,6 @@ case "$( uname )" in #( esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then @@ -173,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -223,13 +220,10 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. -# -# Before gradle 8.14 were not support using an executable JAR for the wrapper. -# It causes a no main manifest attribute error if developers use the old wrapper. + set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. From 3a0fe9715209748f9a4e43e13f154493f0d7dfdd Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Fri, 10 Oct 2025 17:43:51 +0800 Subject: [PATCH 05/12] verifying the version of wrapper jar --- gradlew | 19 +++++++++++++++++++ wrapper.gradle | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/gradlew b/gradlew index 98a05d787ee04..6d950375b45e3 100755 --- a/gradlew +++ b/gradlew @@ -201,6 +201,7 @@ fi # Loop in case we encounter an error. +REQUIRED_WRAPPER_JAR_CHECKSUM=$(curl -sSL "https://services.gradle.org/distributions/gradle-9.1.0-wrapper.jar.sha256") for attempt in 1 2 3; do if [ ! -e "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" ]; then if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v9.1.0/gradle/wrapper/gradle-wrapper.jar"; then @@ -209,6 +210,24 @@ for attempt in 1 2 3; do sleep 5 continue fi + else + # Verify checksum of existing wrapper JAR. + # Use sha256sum or shasum, whichever is available. + if command -v sha256sum >/dev/null 2>&1; then + LOCAL_WRAPPER_JAR_CHECKSUM=$(sha256sum "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" | awk '{print $1}') + elif command -v shasum >/dev/null 2>&1; then + LOCAL_WRAPPER_JAR_CHECKSUM=$(shasum -a 256 "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" | awk '{print $1}') + else + # If no checksum tool is found, delete the JAR and re-download. + warn "Cannot find sha256sum or shasum to verify wrapper JAR. Deleting and re-downloading." + rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" + continue + fi + + # If the local checksum does not match the required checksum, delete the JAR to force re-download. + if [ "$LOCAL_WRAPPER_JAR_CHECKSUM" != "$REQUIRED_WRAPPER_JAR_CHECKSUM" ] ; then + rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" + fi fi done diff --git a/wrapper.gradle b/wrapper.gradle index 4cd9fc65f9d45..9bd5cd6ae271d 100644 --- a/wrapper.gradle +++ b/wrapper.gradle @@ -42,9 +42,11 @@ task bootstrapWrapper() { // fetch the jar. def wrapperBaseUrl = "https://raw.githubusercontent.com/gradle/gradle/v$versions.gradle/gradle/wrapper" def wrapperJarUrl = wrapperBaseUrl + "/gradle-wrapper.jar" + def wrapperJarChecksumUrl = "https://services.gradle.org/distributions/gradle-$versions.gradle-wrapper.jar.sha256" def bootstrapString = """ # Loop in case we encounter an error. + REQUIRED_WRAPPER_JAR_CHECKSUM=\$(curl -sSL "$wrapperJarChecksumUrl") for attempt in 1 2 3; do if [ ! -e "$wrapperJarPath" ]; then if ! curl -s -S --retry 3 -L -o "$wrapperJarPath" "$wrapperJarUrl"; then @@ -53,6 +55,24 @@ task bootstrapWrapper() { sleep 5 continue fi + else + # Verify checksum of existing wrapper JAR. + # Use sha256sum or shasum, whichever is available. + if command -v sha256sum >/dev/null 2>&1; then + LOCAL_WRAPPER_JAR_CHECKSUM=\$(sha256sum "$wrapperJarPath" | awk '{print \$1}') + elif command -v shasum >/dev/null 2>&1; then + LOCAL_WRAPPER_JAR_CHECKSUM=\$(shasum -a 256 "$wrapperJarPath" | awk '{print \$1}') + else + # If no checksum tool is found, delete the JAR and re-download. + warn "Cannot find sha256sum or shasum to verify wrapper JAR. Deleting and re-downloading." + rm -f "$wrapperJarPath" + continue + fi + + # If the local checksum does not match the required checksum, delete the JAR to force re-download. + if [ "\$LOCAL_WRAPPER_JAR_CHECKSUM" != "\$REQUIRED_WRAPPER_JAR_CHECKSUM" ] ; then + rm -f "$wrapperJarPath" + fi fi done """.stripIndent() From 5c936800ecdd89e6cf46a209f19a361cdc2dd9ef Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Fri, 10 Oct 2025 20:42:50 +0800 Subject: [PATCH 06/12] hardcode required checksum and add comments --- gradlew | 5 +++-- wrapper.gradle | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gradlew b/gradlew index 6d950375b45e3..639977ca25997 100755 --- a/gradlew +++ b/gradlew @@ -201,7 +201,7 @@ fi # Loop in case we encounter an error. -REQUIRED_WRAPPER_JAR_CHECKSUM=$(curl -sSL "https://services.gradle.org/distributions/gradle-9.1.0-wrapper.jar.sha256") +REQUIRED_WRAPPER_JAR_CHECKSUM="76805e32c009c0cf0dd5d206bddc9fb22ea42e84db904b764f3047de095493f3" for attempt in 1 2 3; do if [ ! -e "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" ]; then if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v9.1.0/gradle/wrapper/gradle-wrapper.jar"; then @@ -211,7 +211,8 @@ for attempt in 1 2 3; do continue fi else - # Verify checksum of existing wrapper JAR. + # Verify checksum of existing wrapper JAR. + # This prevents developers from running into incompatibility issues when using an outdated wrapper JAR after a Gradle upgrade. # Use sha256sum or shasum, whichever is available. if command -v sha256sum >/dev/null 2>&1; then LOCAL_WRAPPER_JAR_CHECKSUM=$(sha256sum "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" | awk '{print $1}') diff --git a/wrapper.gradle b/wrapper.gradle index 9bd5cd6ae271d..6ba1124aca94d 100644 --- a/wrapper.gradle +++ b/wrapper.gradle @@ -42,11 +42,12 @@ task bootstrapWrapper() { // fetch the jar. def wrapperBaseUrl = "https://raw.githubusercontent.com/gradle/gradle/v$versions.gradle/gradle/wrapper" def wrapperJarUrl = wrapperBaseUrl + "/gradle-wrapper.jar" - def wrapperJarChecksumUrl = "https://services.gradle.org/distributions/gradle-$versions.gradle-wrapper.jar.sha256" + // IMPORTANT: This checksum **must** be updated whenever the Gradle version changes. + String wrapperChecksum = "76805e32c009c0cf0dd5d206bddc9fb22ea42e84db904b764f3047de095493f3" def bootstrapString = """ # Loop in case we encounter an error. - REQUIRED_WRAPPER_JAR_CHECKSUM=\$(curl -sSL "$wrapperJarChecksumUrl") + REQUIRED_WRAPPER_JAR_CHECKSUM="$wrapperChecksum" for attempt in 1 2 3; do if [ ! -e "$wrapperJarPath" ]; then if ! curl -s -S --retry 3 -L -o "$wrapperJarPath" "$wrapperJarUrl"; then @@ -56,7 +57,8 @@ task bootstrapWrapper() { continue fi else - # Verify checksum of existing wrapper JAR. + # Verify checksum of existing wrapper JAR. + # This prevents developers from running into incompatibility issues when using an outdated wrapper JAR after a Gradle upgrade. # Use sha256sum or shasum, whichever is available. if command -v sha256sum >/dev/null 2>&1; then LOCAL_WRAPPER_JAR_CHECKSUM=\$(sha256sum "$wrapperJarPath" | awk '{print \$1}') From 673dab092f04dadcd843333c07a619a7eb94294d Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Sat, 11 Oct 2025 15:55:53 +0800 Subject: [PATCH 07/12] add break --- gradlew | 2 ++ wrapper.gradle | 2 ++ 2 files changed, 4 insertions(+) diff --git a/gradlew b/gradlew index 639977ca25997..54d757905bff2 100755 --- a/gradlew +++ b/gradlew @@ -228,6 +228,8 @@ for attempt in 1 2 3; do # If the local checksum does not match the required checksum, delete the JAR to force re-download. if [ "$LOCAL_WRAPPER_JAR_CHECKSUM" != "$REQUIRED_WRAPPER_JAR_CHECKSUM" ] ; then rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" + else + break fi fi done diff --git a/wrapper.gradle b/wrapper.gradle index 6ba1124aca94d..77e9aa887f6db 100644 --- a/wrapper.gradle +++ b/wrapper.gradle @@ -74,6 +74,8 @@ task bootstrapWrapper() { # If the local checksum does not match the required checksum, delete the JAR to force re-download. if [ "\$LOCAL_WRAPPER_JAR_CHECKSUM" != "\$REQUIRED_WRAPPER_JAR_CHECKSUM" ] ; then rm -f "$wrapperJarPath" + else + break fi fi done From 1512bc93e99130b169c5872ac3491a2a37bdbf36 Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Mon, 13 Oct 2025 23:34:38 +0800 Subject: [PATCH 08/12] Adjust the handling method when there is no checksum tool --- gradlew | 6 ++---- wrapper.gradle | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gradlew b/gradlew index 54d757905bff2..16d3eb6dbd584 100755 --- a/gradlew +++ b/gradlew @@ -219,10 +219,8 @@ for attempt in 1 2 3; do elif command -v shasum >/dev/null 2>&1; then LOCAL_WRAPPER_JAR_CHECKSUM=$(shasum -a 256 "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" | awk '{print $1}') else - # If no checksum tool is found, delete the JAR and re-download. - warn "Cannot find sha256sum or shasum to verify wrapper JAR. Deleting and re-downloading." - rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" - continue + # If no checksum tool is found, exit with an error. + die "ERROR: Cannot find sha256sum or shasum to verify wrapper JAR. Please install one of these tools." fi # If the local checksum does not match the required checksum, delete the JAR to force re-download. diff --git a/wrapper.gradle b/wrapper.gradle index 77e9aa887f6db..4c271a6e5b7dd 100644 --- a/wrapper.gradle +++ b/wrapper.gradle @@ -65,10 +65,8 @@ task bootstrapWrapper() { elif command -v shasum >/dev/null 2>&1; then LOCAL_WRAPPER_JAR_CHECKSUM=\$(shasum -a 256 "$wrapperJarPath" | awk '{print \$1}') else - # If no checksum tool is found, delete the JAR and re-download. - warn "Cannot find sha256sum or shasum to verify wrapper JAR. Deleting and re-downloading." - rm -f "$wrapperJarPath" - continue + # If no checksum tool is found, exit with an error. + die "ERROR: Cannot find sha256sum or shasum to verify wrapper JAR. Please install one of these tools." fi # If the local checksum does not match the required checksum, delete the JAR to force re-download. From 039e08cde00f2004b5107d1229ab9351be66cabc Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Tue, 14 Oct 2025 08:16:05 +0800 Subject: [PATCH 09/12] skip checksum if no tools --- gradlew | 3 ++- wrapper.gradle | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gradlew b/gradlew index 16d3eb6dbd584..79876896bebf9 100755 --- a/gradlew +++ b/gradlew @@ -220,7 +220,8 @@ for attempt in 1 2 3; do LOCAL_WRAPPER_JAR_CHECKSUM=$(shasum -a 256 "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" | awk '{print $1}') else # If no checksum tool is found, exit with an error. - die "ERROR: Cannot find sha256sum or shasum to verify wrapper JAR. Please install one of these tools." + warn "Cannot find sha256sum or shasum to verify wrapper JAR." + break fi # If the local checksum does not match the required checksum, delete the JAR to force re-download. diff --git a/wrapper.gradle b/wrapper.gradle index 0473ef88d8154..ca53f2e19e2e1 100644 --- a/wrapper.gradle +++ b/wrapper.gradle @@ -65,7 +65,8 @@ task bootstrapWrapper() { LOCAL_WRAPPER_JAR_CHECKSUM=\$(shasum -a 256 "$wrapperJarPath" | awk '{print \$1}') else # If no checksum tool is found, exit with an error. - die "ERROR: Cannot find sha256sum or shasum to verify wrapper JAR. Please install one of these tools." + warn "Cannot find sha256sum or shasum to verify wrapper JAR." + break fi # If the local checksum does not match the required checksum, delete the JAR to force re-download. From 3ab92f0760392f8f6ff51b77824b6a61886ae059 Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Fri, 17 Oct 2025 08:21:52 +0800 Subject: [PATCH 10/12] fix comments --- wrapper.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrapper.gradle b/wrapper.gradle index ca53f2e19e2e1..bda27ab14349f 100644 --- a/wrapper.gradle +++ b/wrapper.gradle @@ -64,7 +64,7 @@ task bootstrapWrapper() { elif command -v shasum >/dev/null 2>&1; then LOCAL_WRAPPER_JAR_CHECKSUM=\$(shasum -a 256 "$wrapperJarPath" | awk '{print \$1}') else - # If no checksum tool is found, exit with an error. + # If no checksum tool is found, this verification is skipped . warn "Cannot find sha256sum or shasum to verify wrapper JAR." break fi From 0bf201c15b8b061e2d82095f5d6d03284325f8b0 Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Fri, 17 Oct 2025 08:23:07 +0800 Subject: [PATCH 11/12] fix comments --- gradlew | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradlew b/gradlew index 79876896bebf9..2cb83c664d83c 100755 --- a/gradlew +++ b/gradlew @@ -219,7 +219,7 @@ for attempt in 1 2 3; do elif command -v shasum >/dev/null 2>&1; then LOCAL_WRAPPER_JAR_CHECKSUM=$(shasum -a 256 "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" | awk '{print $1}') else - # If no checksum tool is found, exit with an error. + # If no checksum tool is found, this verification is skipped . warn "Cannot find sha256sum or shasum to verify wrapper JAR." break fi From 46989569b975dc06ba59983352027e035d7f43bd Mon Sep 17 00:00:00 2001 From: Chih-Yuan Chien Date: Fri, 17 Oct 2025 21:55:28 +0800 Subject: [PATCH 12/12] merge url and move checksum variable --- wrapper.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wrapper.gradle b/wrapper.gradle index bda27ab14349f..cd1de19c3d61a 100644 --- a/wrapper.gradle +++ b/wrapper.gradle @@ -39,10 +39,9 @@ task bootstrapWrapper() { // github.com servers deprecated TLSv1/TLSv1.1 support some time ago, so older versions // of curl (built against OpenSSL library that doesn't support TLSv1.2) would fail to // fetch the jar. - def wrapperBaseUrl = "https://raw.githubusercontent.com/gradle/gradle/v$versions.gradle/gradle/wrapper" - def wrapperJarUrl = wrapperBaseUrl + "/gradle-wrapper.jar" // IMPORTANT: This checksum **must** be updated whenever the Gradle version changes. String wrapperChecksum = "76805e32c009c0cf0dd5d206bddc9fb22ea42e84db904b764f3047de095493f3" + def wrapperJarUrl = "https://raw.githubusercontent.com/gradle/gradle/v$versions.gradle/gradle/wrapper/gradle-wrapper.jar" def bootstrapString = """ # Loop in case we encounter an error.