gradle Gradle Wrapper Gradle Wrapper and Git


Example

As discussed in the introduction, the gradle wrapper functionality works because a jar is downloaded into the project to be used when the gradlew command is run. However this may not get committed and after the next time the project is checked out, gradlew will fail to run with the error:

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

This will be because your .gitignore will likely include *jar for Java projects. When the gradle wrapper was initialised, it copies to the file gradle/wrapper/gradle-wrapper.jar. Thus you need to add it to the git index and commit it. Do so with:

git add -f gradle/wrapper/gradle-wrapper.jar
git ci

With the -f being to force it.