Adding gradle wrapper files to gitignore


(Sverre Moe) #1

Why are people checking in these files to git?
gradlew
gradlew.bat
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties

I have added these files to .gitignore. I don’t like having such files to VCS.

The recommended way to execute any Gradle build is with the help of the Gradle Wrapper (in short just “Wrapper”). The Wrapper is a script that invokes a declared version of Gradle, downloading it beforehand if necessary.

I see projects having commits where the gradle-wrapper.properties gets updated with new Gradle version, and a JAR file in the git repository is a monstrosity.
Like this one: https://github.com/gradle-guides/building-java-9-modules

They way I see Gradle Wrapper it is a “download manager” for Gradle and a “wrapper” for the gradle executable. You would need to continue to use the Gradle Wrapper if you want to use the distributions it downloads, instead of the system installed Gradle.

I see no point in checking in these files. They can be generated just by calling gradle wrapper. If all you need is to set a gradle version for the project, why not just put it in settings.gradle and have it used when calling gradle wrapper.

Having to make commits like this one is ridiculous.
https://github.com/javafxports/openjdk-jfx/pull/92/commits/0a32097ed211cb358d3c02c638fe5e73929e4d76


(René Groeschke) #2

Hey
the gradle wrapper files are meant to be stored along with the other sources of your project in the version control system. the two main benefits of using the wrapper:

  • Standardizes a project on a given Gradle version, leading to more reliable and robust builds.
  • Provisioning a new Gradle version to different users and execution environment (e.g. IDEs or Continuous Integration servers) is as simple as changing the Wrapper definition.

If you would have just run the wrapper task as provisioning step to install the proper gradle version, you would still rely on the fact that you need gradle to invoke this wrapper task. a chicken egg problem so to say. instead the wrapper scripts don’t require any gradle installation on the machine they’re executed. We also work hard to keep the wrapper jar as small as possible.

More information about the wrapper can be found in the according user guide at https://docs.gradle.org/current/userguide/gradle_wrapper.html

Hope that helps,

cheers,
René