Why should the Gradle Wrapper be committed to VCS?

后端 未结 6 1826
甜味超标
甜味超标 2021-01-29 23:49

From Gradle\'s documentation: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.wrapper.Wrapper.html

The scripts generated by this

6条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 00:26

    Because the whole point of the Gradle wrapper is to be able, without having ever installed Gradle

    Same argument goes for the JDK, do you want to commit that also? Do you also commit all your dependency libraries?

    The dependencies should be upgraded continuously as new versions are released to get security and other bug fixes, and because if you get to far behind it can be a very time consuming task to get up to date again.

    If the Gradle wrapper is incremented for every new release, and it is committed, the repo will grow very large. The problem is obvious when working with distributed VCS where a clone will download all versions of everything.

    and without even knowing how it works

    Create a build script that downloads the wrapper and uses it to build. Everyone does not need to know how the script works, they need to agree that the project is build by executing it.

    where to download it from, which version

    task wrapper(type: Wrapper) {
      gradleVersion = 'X.X' 
    }
    

    and then

    gradle wrapper
    

    to download the correct version.

    to clone the project from the VCS, to execute the gradlew script it contains, and to build the project without any additional step.

    Solved by the steps above. Downloading the Gradle wrapper is not different from downloading any other dependency. The script could be smart enough to check for any current Gradle wrapper and only download it if there is a new version.

    If the developer has never used Gradle before and maybe doesn't know the project is built with Gradle, then it is more obvious to run a build.sh compared to running gradlew build.

    If all you had was a gradle version number in a build.gradle file, you would need a README explaining everyone that gradle version X must be downloaded from URL Y an installed,

    No, you would not need a README. You could have one, but we are developers and we should automate as much as possible. Creating a script is better.

    and you would have to do it every time the version is incremented.

    If the developers agree that the correct process is to:

    1. Clone repo
    2. Run build script

    Then there upgrading to latest Gradle wrapper is no problem. If the version is incremented since last run, the script could download the new version.

提交回复
热议问题