你的位置:首页 > 软件开发 > 操作系统 > Chapter 5. The Gradle Wrapper 关于gradle wrapper

Chapter 5. The Gradle Wrapper 关于gradle wrapper

发布时间:2016-05-27 07:00:28
Most tools require installation on your computer before you can use them. If the installation is easy, you may think that’s fine. ...

Most tools require installation on your computer before you can use them. If the installation is easy, you may think that’s fine. But it can be an unnecessary burden on the users of the build. Equally importantly, will the user install the right version of the tool for the build? What if they’re building an old version of the software?

//大多数工具需要在使用前安装,如果安装容易还好,但是如果因为安装的麻烦而惹恼用户就不太好了。而同样重要的是用户是否安装的正确的版本,假如用户正在使用旧版本软件构建呢?

The Gradle Wrapper (henceforth referred to as the “Wrapper”) solves both these problems and is the preferred way of starting a Gradle build.

//Gradle Wrapper ,以后简称为Wrapper,解决了这两个问题,这也是gradle 构建的优选方法

5.1. Executing a build with the Wrapper

//使用wrapper执行构建

The Wrapper can be further customized by adding and configuring a Wrapper task in your build script, and then executing it.

//wrapper可以在build脚本中添加wrapper 任务来深度定制化,然后执行它。

Example 5.2. Wrapper task

build.gradle

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

After such an execution you find the following new or updated files in your project directory (in case the default configuration of the Wrapper task is used).

//在执行完上面的脚本,你会发现在项目中生成了下面这些新的或者修改的文件(以防使用默认配置)

Example 5.3. Wrapper generated files

Build layout

simple/ gradlew gradlew.bat gradle/wrapper/  gradle-wrapper.jar  gradle-wrapper.properties

All of these files should be submitted to your version control system. This only needs to be done once. After these files have been added to the project, the project

//所有的这些文件将会提交到版本库中。所以这个任务只需要执行一次。当这些文件添加到项目中后,

should then be built with the added gradlew command. The gradlew command can be used exactly the same way as the gradle command.

//项目之后会使用gradlew命令来构建,gradlew命令用法可gradle一样

If you want to switch to a new version of Gradle you don't need to rerun the wrapper task. It is good enough to change the respective entry in thegradle-wrapper.properties file, but if you want to take advantage of new functionality in the Gradle wrapper, then you would need to regenerate the wrapper files.

//如果你想切换到gradle的新版本,只需要修改gradle-wrapper.properties 文件

Add the returned hash sum to the gradle-wrapper.properties using the distributionSha256Sum property.

Example 5.5. Configuring SHA-256 checksum verification

gradle-wrapper.properties

distributionSha256Sum=371cb9fbebbe9880d147f59bab36d61eee122854ef8c9ee1ecf12b82368bcf10

原标题:Chapter 5. The Gradle Wrapper 关于gradle wrapper

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录