如何将Gradle依赖关系更新为最新版本 [英] How to update Gradle dependencies to their latest version

查看:257
本文介绍了如何将Gradle依赖关系更新为最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以让gradle将依赖关系更新到最新的可用版本?

为了构建可重复性,我所有的依赖关系都使用这样的版本号来定义我的build.gradle文件:

 依赖关系{
编译'namespace:package1:version'
compile' namespace:package2:version'
compile'namespace:package3:version'
}



<定期我想将每个软件包更新到最新版本。通常情况下,这是我在发布新版本后为新sprint做的第一件事。



手动为每个包执行此操作确实很痛苦。理想情况下,我想要一个命令为我更新build.gradle文件,但至少有一个命令可以打印出哪个软件包需要更新以及最新版本号是什么。



在红宝石般的土地上,我会运行bundler update。 解决方案

这就是我所能想到的。我会很高兴地接受另一个答案,如果有一个较少的手动方法做到这一点。


  1. 在Android Studio中,我将每个依赖版本加上一个例子: compile'namespace:package1:+'


  2. 同步或建立项目将导致所有依赖项被解析为最新版本。在Android Studio中,将光标放在build.gradle中的每个依赖关系行上,然后按 alt + enter 弹出菜单,您可以选择替换为特定版本



Is there an easy way to get gradle to update dependencies to their latest available version?

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'
}

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.

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.

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.

  1. In Android studio I replace every dependency version with a plus example: compile 'namespace:package1:+'

  2. Sync or build the project which will cause all the dependencies to be resolved to their latest version.

  3. 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屋!

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