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

查看:232
本文介绍了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版本(带有带有版本定义的单独的Versions类)上测试了此Gradle Dependencies Update Check插件,并且对我来说效果很好:

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天全站免登陆