其实就是对于gradle 的一个包装,保证了项目版本的一致,同时减少配置
1. 生成wrapper
// 使用gradle wrapper 命令
gradle wrapper
输出效果如下:
[root@iZ2zeg7uro1snhd9wqmp2oZ first]# gradle wrapper
Starting a Gradle Daemon (subsequent builds will be faster)
BUILD SUCCESSFUL in 3s
1 actionable task: 1 executed
目录结构
.
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
└── gradlew.bat
2. wrapper 配置
// 版本、发行版本下载地址
--gradle-version
--gradle-distribution-url
gradle-wrapper.properties (gradle/wrapper 目录)
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-4.3.1-bin.zip
3. 自定义wrapper task
添加build.gradle
task wrapper(type:Wrapper) {
gradleVersion="4.1"
}
类似对应的gradle 版本就会修改如下:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-bin.zip
4. 参考文档
https://docs.gradle.org/4.3.1/userguide/gradle_wrapper.html