简体   繁体   English

是否有任何自动化的方法来使用Gradle更新和管理Java / Scala依赖关系?

[英]Is there any automated way to update and manage Java/Scala dependencies with Gradle?

I've recently returned to working on a Scala project, after having spent some time working with the nodejs ecosystem. 在花了一些时间处理nodejs生态系统之后,我最近回到了Scala项目的工作。 After getting used to package managers like npm and yarn , I feel like I need to rethink the tools/processes I've been using for Java/Scala. 习惯了像npmyarn这样的软件包管理器之后,我觉得我需要重新考虑我一直在Java / Scala中使用的工具/过程。 With that in mind, there are several problems which appear to exist in the JVM world for which I'd like to know if there's some automated solution: 考虑到这一点,JVM世界似乎存在一些问题,我想知道是否存在一些自动化解决方案:

  1. Given some list of dependencies without versions (but with group, module), is there some automated way to detect what the valid combinations (if any exist) of versions for each dependency are? 给定一些没有版本的依赖关系列表(但带有组,模块),是否有某种自动方法来检测每个依赖关系的有效版本组合(如果存在)? Specifically, ensuring that there are no conflicting transitive dependencies? 具体来说,要确保没有冲突的传递依赖项?
    I believe Java Modules should reduce/eliminate this issue, but I'm currently limited to Java 8 so can't use them. 我相信Java模块应该减少/消除此问题,但是我目前仅限于Java 8,因此无法使用它们。

  2. Aside from manually changing version numbers in my build.gradle , is there any automated way to update a dependency from cli? 除了在build.gradle手动更改版本号build.gradle ,是否还有任何自动方法可以从cli更新依赖项?
    For example, I can do yarn install <package>@<version> to record the new version of a nodejs library I depend on and install it in one step - does anything similar exist for JVM projects? 例如,我可以执行yarn install <package>@<version>来记录我依赖的nodejs库的新版本, 然后一步安装它 -JVM项目是否存在类似的东西?

  3. Are there any tools similar to updtr for Java/Scala projects? 是否有任何类似于updtr的Java / Scala项目工具? Basically; 基本上; a tool that will automatically try to update my dependencies and run tests with the new versions, and rollback if anything fails. 该工具将自动尝试更新我的依赖项并使用新版本运行测试,如果出现任何故障,则回滚。


In case it matters, I'm currently using gradle as my build tool in a Scala 2.11 project; 如果很重要,我目前在Scala 2.11项目中使用gradle作为构建工具。 but I'm curious to know about any answers that would apply to any mixed language project using any build tool. 但是我很想知道使用任何构建工具适用于任何混合语言项目的任何答案。 Ultimately I just want to avoid manually checking every one of my dependencies against every other dependency manually - anything else is an extra nicety. 最终,我只想避免手动检查我的每个依赖项与其他所有依赖项之间的手动关系-其他任何事情都是多余的。

I can answer only point 3 of your question, and even this - only partially. 我只能回答您问题的第3点,甚至只能部分回答。

You might be interested in Gradle Versions Plugin by Ben Manes . 您可能会感兴趣的摇篮版本插件通过本Manes认为

This plugin does not update your dependencies (so all the more it does not have the test-running + rollback functionality). 这个插件更新你的依赖(所以更加具备测试运行+回滚功能)。

However, it will list all the dependencies that can be upgraded, like that (it's only one of the possible formats): 但是,它将列出所有可以升级的依赖项,就像这样(它只是可能的格式之一):

 The following dependencies are using the latest integration 以下依赖项使用的是最新集成\nversion: 版:\n - backport-util-concurrent:backport-util-concurrent:3.1 -backport-util-concurrent:backport-util-concurrent:3.1\n - backport-util-concurrent:backport-util-concurrent-java12:3.1 -backport-util-concurrent:backport-util-concurrent-java12:3.1\n\nThe following dependencies exceed the version found at the integration 以下依赖项超出了集成时找到的版本\nrevision level: 修订级别:\n - com.google.guava:guava [99.0-SNAPSHOT 3.0] -com.google.guava:guava [99.0-SNAPSHOT 3.0]\n     http://code.google.com/p/google-guice/ http://code.google.com/p/google-guice/\n - com.google.inject.extensions:guice-multibindings [2.0 -> 3.0] -com.google.inject.extensions:guice-multibindings [2.0-> 3.0]\n     http://code.google.com/p/google-guice/ http://code.google.com/p/google-guice/\n\nGradle updates: 摇篮更新:\n - Gradle: [4.6 -> 4.7 -> 4.8-rc-2] -摇篮:[4.6-> 4.7-> 4.8-rc-2] 

Source: Report format 资料来源: 报告格式

Moreover, the plugin can be configured as to what is not considered to be an upgradeable version: 此外,可以将插件配置为被视为可升级版本的版本:

 boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier -> selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\\d-]*/ } 

Source: Revisions 资料来源: 修订本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM