Android Studio:“使用默认的 gradle 包装器"vs. “使用可定制的 gradle 包装器" [英] Android Studio: "Use default gradle wrapper" vs. "Use customizable gradle wrapper"

查看:27
本文介绍了Android Studio:“使用默认的 gradle 包装器"vs. “使用可定制的 gradle 包装器"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Studio 的 Gradle 选项之间究竟有什么区别:

What exactly is the difference between Android Studio's Gradle options:

Android Studio->Preferences->Gradle

使用默认的 gradle 包装器(推荐)使用可自定义的 gradle 包装器?

背景:

我正在 Android Studio 中处理一个 Android 项目并使用 Gradle 包装器.

I am working on an Android project in Android Studio and using a Gradle wrapper.

但是,每当我的团队成员使用 gui 命令同步 Android Studio 项目时,当我使用 Android Studio 设置使用可自定义的 gradlew 包装器"时:

However, when I use the Android Studio settings "Use customizable gradlew wrapper" every time my team members sync the Android Studio project using the gui command:

他们发现 gradle/wrapper/gradle-wrapper.properties 日期正在更新(并导致 git repo 上的额外差异).

they find the gradle/wrapper/gradle-wrapper.properties date being updated (and resulting in a extra diffs on the git repo).

切换到使用默认的 gradle 包装器"似乎可以解决这个问题.

Switching to "Use default gradle wrapper" seems to solve this issue.

推荐答案

查看 IntelliJ IDEA 帮助 此处:

See the IntelliJ IDEA help here:

  • 使用默认的 gradle 包装器意味着 Gradle 控制版本号
  • 使用可自定义的 gradle 包装器意味着 IDEA 控制着 gradle 包装器的版本号.

版本号存储在 gradle/wrapper/gradle-wrapper.properties 中.所以当你每次用IDEA打开项目时选择使用可定制的gradle wrapper"时,它会改变属性文件来调整你在IDEA项目中指定的wrapper版本.

The version number is stored in gradle/wrapper/gradle-wrapper.properties. So when you choose "using the customizable gradle wrapper" each time you are opening the project with IDEA, it will change the property file to adjust the wrapper version you specified in the IDEA project.

为了可重复构建(即使在不运行 IDEA 的连续构建服务器上),让 Gradle 控制版本号并使用默认的 gradle 包装器.

For the sake of repeatable builds (even on your continuous build server which doesn't run IDEA) let Gradle control the version number and use the default gradle wrapper.

您可以在 build.gradle 中使用

// needs at least Gradle V1.7
wrapper {
    gradleVersion = '2.2.1'
}

// works with every Gradle version
task wrapper(type: Wrapper) {
    gradleVersion = '2.2.1'
}

备注:不要忘记这个配置只用于生成包装器.要激活它,您必须使用 gradlew wrapper 执行生成.此任务会更新 gradle-wrapper.properties,之后用于所有包装器执行.

Remark: don't forget that this configuration is only used for the generation of the wrapper. To activate it, you have to execute the generation with gradlew wrapper. This tasks updates the gradle-wrapper.properties which is used afterwards for all wrapper executions.

这篇关于Android Studio:“使用默认的 gradle 包装器"vs. “使用可定制的 gradle 包装器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆