Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin DSL build scripts dependency updates

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.

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?

like image 245
George Avatar asked Jul 09 '19 11:07

George


People also ask

How do I manage Gradle dependencies?

At runtime, Gradle will locate the declared dependencies if needed for operating a specific task. The dependencies might need to be downloaded from a remote repository, retrieved from a local directory or requires another project to be built in a multi-project setting. This process is called dependency resolution.

What is buildSrc?

buildSrc is a directory at the Gradle project root, which can contain our build logic. This allows us to use the Kotlin DSL to write our custom build code with very little configuration and share this logic across the whole project.

How do I convert build Gradle to kts?

Migrate one file at a timeRename the file to settings. gradle. kts and convert the file's contents to KTS. Make sure that your project still compiles after the migration of each build file.


1 Answers

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 Plugin

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

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")
}

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
like image 92
dnh Avatar answered Sep 17 '22 12:09

dnh