gradle Gradle Wrapper Gradle Wrapper and Git

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any gradle Question?