Skip to content

Commit be2841f

Browse files
docs: clarify CLASSPATH was empty and redundant in old wrapper scripts
Co-authored-by: jiajingjing2016 <137744850+jiajingjing2016@users.noreply.github.com>
1 parent 29f207c commit be2841f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

docs/GRADLE_WRAPPER_CHANGES.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ During the upgrade from Gradle 8.14.2 to Gradle 9.3.1, you may notice that the `
1111
### Before (Gradle 8.14.2 and earlier)
1212
```bash
1313
# In gradlew
14-
CLASSPATH="\\\"\\\""
14+
CLASSPATH="\\\"\\\"" # Empty classpath with escaped quotes
15+
# ... later, for Cygwin/MSYS:
1516
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
1617

1718
# Command execution
@@ -26,6 +27,8 @@ set CLASSPATH=
2627
java -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
2728
```
2829

30+
**Note**: The CLASSPATH was actually empty in both cases, but was still being passed as an argument to Java.
31+
2932
### After (Gradle 9.3.1)
3033
```bash
3134
# In gradlew
@@ -70,21 +73,28 @@ Starting with Gradle 8.14, the Gradle wrapper JAR (`gradle-wrapper.jar`) was upd
7073

7174
### 3. Technical Details
7275

73-
The old approach manually constructed a classpath and specified the main class:
76+
The old approach set an empty CLASSPATH variable and still used `-jar`:
7477
```bash
75-
java -cp gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain [args...]
78+
# Old wrapper scripts
79+
java -classpath "$CLASSPATH" -jar gradle-wrapper.jar [args...]
80+
# The -classpath was redundant because -jar ignores the classpath anyway
7681
```
7782

78-
The new approach uses the executable JAR's manifest:
83+
The new approach removes the redundant classpath:
7984
```bash
85+
# New wrapper scripts
8086
java -jar gradle-wrapper.jar [args...]
8187
```
8288

83-
The `gradle-wrapper.jar` manifest now contains:
89+
**Important**: When you use `java -jar`, Java ignores any `-classpath` or `-cp` argument. The classpath is determined solely by the JAR's manifest `Class-Path` entry and the JAR itself. The old wrapper scripts were passing an empty classpath that was being ignored anyway.
90+
91+
The `gradle-wrapper.jar` manifest contains:
8492
```
8593
Main-Class: org.gradle.wrapper.GradleWrapperMain
8694
```
8795

96+
This is why the simplification works - the classpath was never actually being used.
97+
8898
## Impact on This Project
8999

90100
When we upgraded to Gradle 9.3.1:

0 commit comments

Comments
 (0)