如何将 Gradle 依赖项更新到最新版本 [英] How to update Gradle dependencies to their latest version
问题描述
是否有一种简单的方法可以让 gradle 将依赖项更新到最新的可用版本?
Is there an easy way to get gradle to update dependencies to their latest available version?
为了构建重现性,我的所有依赖项都在我的 build.gradle 文件中定义了这样的版本号:
For build reproducibility all my dependencies are defined with a version number like this in my build.gradle file:
dependencies {
compile 'namespace:package1:version'
compile 'namespace:package2:version'
compile 'namespace:package3:version'
}
我想定期将每个包更新到最新版本.通常这是我在发布后为新 sprint 做的第一件事.
Periodically I want to update every package to their latest version. Typically this is the first thing I do for a new sprint after making a release.
为每个包手动执行此操作真的很痛苦.理想情况下,我想要一个命令来为我更新 build.gradle 文件,但至少有一个命令可以打印出哪个包需要更新以及最新版本号是多少.
It's a real pain doing this manually for each package. Ideally I would like a command to update the build.gradle file for me but at the very least a command that prints out which package needs an update and what the latest version number is.
在 ruby land 我会运行 bundler update.
In ruby land I would run bundler update.
推荐答案
我能想到的就这些.如果有更少的手动方法,我会很乐意接受另一个答案.
This is all I've been able to come up with. I will happily accept another answer if there is a less manual method of doing this.
在 Android Studio 中,我用加号示例替换了每个依赖项版本:
compile 'namespace:package1:+'
同步或构建项目,这将导致所有依赖项解析为最新版本.
Sync or build the project which will cause all the dependencies to be resolved to their latest version.
在 Android Studio 中,将光标放在 build.gradle 中的每个依赖项行上,然后按 alt+enter 会弹出一个菜单,您可以选择替换为特定版本
In Android Studio place the cursor on each dependency line in build.gradle and press alt+enter a menu pops up and you can select Replace with specific version
这篇关于如何将 Gradle 依赖项更新到最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!