Gradle plugin for updating a project version catalog

Gradle is a build automation tool and it can be used for building Android apps. One way to improve the quality of your app is to use Gradle’s versioning plugin, which will compare project versions against one another and report any differences in order to help you update your app properly. This article explains how the Gradle versioning plugin works with examples using GitHub repositories, Node modules, Java libraries and more

Gradle is an open source build tool used to generate projects for Java, Groovy and Scala. This tutorial will show you how to update the version catalog of your project by using a plugin.

The “gradle version catalogs” is a plugin for updating a project’s version catalog. It is also used with the Android Gradle Plugin and Maven.

This plugin aids in the updating of versions in a Gradle version catalog toml file. The versions plugin determines which versions are updated.

Gradle 7.2 or above is required for this plugin. Version catalogs are currently a Gradle incubating feature; for instructions on how to activate this feature, see the documentation.

The versions plugin must be included in the build.gradle or build.gradle.kts files.

Maven Central hosts the version catalog plugin (along with its snapshots). Make sure mavenCentral() is included in your plugin repositories, such as in settings.gradle:

Dependency on pluginManagement mavenCentral() mavenResolutionManagementRepositories

After that, the version catalog update plugin must be installed after the versions plugin.

id “com.github.ben-manes.versions” version “0.39.0” id “nl.littlerobots.version-catalog-update” version “”> plugins id “com.github.ben-manes.versions” version “0.39.0” id “nl.littlerobots.version-catalog-update” version “”

The classpath requirement when utilizing the plugins block is nl.littlerobots.vcu:plugin:

Libs.versions.toml file creation

If you don’t already have a catalog file, you may make one using the —create command line option:

versionCatalogUpdate —create./gradlew

Note that the versions plugin will discover and setup the most recent relevant versions. It is possible to change gradle/libs.version.toml after running the build with —create. You may modify and delete keys that are no longer needed; the versions plugin may contain dependencies that are built into Gradle or that are introduced via other methods, such as plugins.

The plugin will try to produce versions for artifacts that are part of the same group.

As decided by the versions plugin, the catalog will be updated with the most recent available version. The versions plugin allows you to choose which versions are allowed. Unstable versions, such as alphas, are often rejected.

You may adjust your dependent references to utilize the catalog instead of direct dependence declarations once you’ve built the libs.versions.toml file.

The libs.versions.toml file has to be updated.

./gradlew versionCatalogUpdate may be used to update the catalog file at any moment. The following is taken care of as a result of this:

  • The catalog will be updated with new available versions, but current version groups will be preserved if they exist.
  • Versions, libraries, bundles, and plugins will be arranged by name, which may be customized.
  • The bundles will be changed to only include valid keys. A bundle of keys will be sorted.

By default, no new items are added to the catalog, but those that are no longer in use are deleted. Any dependency that isn’t identified by the versions plugin but is still present in the version catalog file is deemed unneeded. This may be changed.

Configuration

The versionCatalogUpdate block in the build file may be used to setup the plugin:

sortyByKey = true addDependencies = false versionCatalogUpdate keepUnused = false; keepUnused = false; keepUnused = false; keepUnused

You may also use command line arguments to alter specified settings. To add dependencies, run./gradlew versionCatalogUpdate —add or./gradlew —keepUnused (or both).

Versions in a flash

Add the Sonatype snapshot repository https://oss.sonatype.org/content/repositories/snapshots/ for snapshot versions.

Issues and restrictions that have been identified

  • “Internal” dependencies or plugins may be added to the catalog when adding dependencies. For this reason, it is advised that the default value be set to false. New dependencies should usually be manually added to the toml file once the first version catalog has been set up.

GitHub

Visit Github for further information.

The “dependabot gradle plugin” is a Gradle plugin that allows users to update the project version catalog. The plugin can be used with any Gradle build system. Reference: dependabot gradle version catalog.

Related Tags

  • gradle version catalog plugins
  • gradle version catalogs buildscript
  • gradle versioning plugin
  • gradle convention plugins
  • gradle version catalog bom