javagradlegradle-wrapper

How to correctly remove the gradle wrapper from VCS?


I don't want to commit the gradle wrapper to VCS¹. Which gradle files could be git-ignored so other users have the least troubles setting up their environment? I'm specifically wondering about gradle/wrapper/gradle-wrapper.properties which may or may not be useful, since it seems to hold the URL to the distribution and its version.

Here's my current gitignore:

/gradlew
/gradlew.bat
/gradle/wrapper/*
!/gradle/wrapper/gradle-wrapper.properties # not sure about this

Does it look right?

¹ Why?

(not relevant, but I anticipate answers beside the point, I'm not looking to negociate)

Even though it is recommended by the Gradle team themselves, comitting the wrapper to VCS sounds like a really bad idea:


Solution

  • You don't need to keep the gradle.properties file if you have specified a desired version in build.gradle like:

    // build.gradle.kts
    
    tasks.wrapper {
        gradleVersion = "7.6"
        distributionType = Wrapper.DistributionType.ALL
    }
    

    So when you/teammate call gradle wrapper, the gradle.properties will be generated with specified version.

    Ref: https://docs.gradle.org/current/userguide/gradle_wrapper.html