Kotlin DSL 构建脚本依赖更新 [英] Kotlin DSL build scripts dependency updates

查看:24
本文介绍了Kotlin DSL 构建脚本依赖更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何从使用 groovy 脚本迁移到使用 Kotlin DSL 进行 Gradle 依赖管理是管理构建脚本的理想方式以及其他提到的优势,已经有大量文章.

There has been a myriad of articles written about how migrating from using groovy scripts to using Kotlin DSL for Gradle dependency management is an ideal way to manage build scripts among other mentioned advantages.

然而,我发现的限制是缺乏这种 Gradle 管理方式或流程,无法像以前使用 groovy 脚本那样突出显示当前依赖项的新版本何时可用.我发现的当前解决方案包括使用插件或实用程序扫描您的 buildSrc 文件夹并将更新作为对当前版本库的注释提供.其中一些包括以下内容:

However, the limitation that I have found is the lack of this Gradle management way or process in highlighting when new versions of the current dependencies are available as was done previously using groovy scripts. The current solutions that I have found include the use of plugins or utilities that scan through your buildSrc folder and provide the updates as comments to the current versions of the libraries. Some of which include the following:

buildSrcVersions

Gradle-versions-plugin

除了我提到的几个插件之外,还有其他有效的方法来检查依赖项更新吗?

Apart from the few plugins that I have mentioned is there any other efficient methods of checking for dependency updates?

推荐答案

我已经在我的 Android/Kotlin DSL 构建中测试了这个 Gradle Dependencies Update Check Plugin(带有一个带有版本定义的单独 Versions 类)并且它对我来说很好用:

I've tested this Gradle Dependencies Update Check Plugin on my Android/Kotlin DSL build (with a separate Versions class with versions definitions) and it works fine for me:

CheckDependencyUpdates Gradle 插件

(我还测试过它适用于传统的 Groovy-DSL 项目)

(I've also tested that it works with a traditional Groovy-DSL project)

要安装插件(从链接页面复制),请将以下内容添加到您的 build.gradle.kts.请注意,我已经从中删除了版本号,因为与我链接到的页面不同,它会过时:

To install the plugin (copied from linked page) add the following to your build.gradle.kts. Note that I've removed the version number from this as it will, unlike the page I've linked to, get out of date:

plugins {
  id("name.remal.check-dependency-updates")
}

要运行更新检查(从 gradle tasks 复制),请运行以下命令:

To run the update check (copied from gradle tasks) run the following:

gradle checkDependencyUpdates

您将看到类似于以下内容的输出部分:

You will see an output section similar to the following:

New dependency version: com.android.tools.build:aapt2: 3.6.1-6040484 -> 3.6.3-6040484
New dependency version: com.android.tools.lint:lint-gradle: 26.6.1 -> 26.6.3

这篇关于Kotlin DSL 构建脚本依赖更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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