Gradle wrapper "Could not find or load main class org.gradle.wrapper.GradleWrapperMain" (missing jar) in CI
./gradlew runs the tiny bootstrap jar gradle/wrapper/gradle-wrapper.jar. When that jar is missing from the checkout, the JVM cannot find GradleWrapperMain and the build fails before Gradle starts.
What this error means
Running ./gradlew fails with "Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain" even though gradlew and gradle-wrapper.properties are present.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMainCommon causes
The wrapper jar was gitignored or never committed
A broad *.jar ignore rule or an incomplete gradle wrapper run left gradle-wrapper.jar out of the repository, so the checkout has no bootstrap class.
A shallow or filtered checkout dropped the jar
A sparse checkout or LFS filter excluded the binary jar, so it is absent on the runner.
How to fix it
Regenerate and commit the wrapper jar
- Run
gradle wrapperlocally to regenerate the full wrapper set. - Force-add the jar past any ignore rule.
- Commit
gradle/wrapper/gradle-wrapper.jarso CI can run./gradlew.
gradle wrapper --gradle-version 8.7
git add -f gradle/wrapper/gradle-wrapper.jarStop ignoring the wrapper jar
Exclude the wrapper jar from any *.jar ignore so it stays in version control.
# .gitignore
*.jar
!gradle/wrapper/gradle-wrapper.jarHow to prevent it
- Commit
gradle-wrapper.jarand exempt it from*.jarignores. - Verify
./gradlew --versionworks on a fresh clone. - Use
actions/checkoutwithout sparse filters that drop the jar.