Thriving.dev Learning Resources for Software Architects and Engineers
Blog Post

Streamline Micronaut + Gradle Updates with Renovate (1/4)

Posted on Feb 6 4min read intermediate

TLDR: Renovate cannot automatically update Micronaut dependencies for gradle projects created via 'Launch' or CLI. This first part dives into why. Parts 2-4 present different solutions.

Blog header image showing the logos of Micronaut, Gradle and Mend Renovate

This first part of a 4-part series dives into why Renovate can't automatically update Micronaut dependencies in Gradle projects created through Launch or CLI. Don't despair! Parts 2-4 unveil alternative solutions to get your updates flowing smoothly. Buckle up and join the quest for effortless Micronaut dependency management!

What?

First things first, let's define what do we want to achieve. Here's our user story:

As a Software Developer, I want to use Renovate to automate keeping a Micronaut Gradle project up-to-date.

Info

Mend Renovate (RenovateBot) is an open-source tool that automates the process of keeping software dependencies up-to-date by scanning code repositories, identifying outdated dependencies, and generating automated pull/merge requests to update them.

The recommended way to add renovate to your GitHub repository is to use the Renovate GitHub App.

Problem Statement

To tick off the basics, Renovate can update Java, Gradle and Maven dependencies. This includes libraries and plugins as well as the Gradle Wrapper.

The manager for Gradle makes use of the maven datasource.
Renovate can be configured to access more repositories and access repositories authenticated, such as e.g. Artifactory.
Maven Central is supported by default.

So if everything needed is in place, why are Micronaut projects not updatable then? The answer lies with how Micronaut manages the transitive dependencies of Micronaut modules.

Micronaut Gradle Plugin

To make the developer experience as smooth as possible, Micronaut provides its own Micronaut Gradle Plugin.

There are actually multiple ones, even...! A typical Micronaut Application, with support for GraalVM and Docker, that one that is pre-configured for projects created via Launch or CLI is io.micronaut.application. (ref https://plugins.gradle.org/plugin/io.micronaut.application)

Selecting the Micronaut Platform Version

The easiest is to set micronautVersion in gradle.properties. If you use a version catalog, you can also set the version of Micronaut directly in your libs.versions.toml file:

[versions]
micronaut="4.0.0"

This version will be shared by all Micronaut modules of your project. Alternatively, you can set the version in your build.gradle(.kts):

micronaut {
    version("4.2.1")
}

Dazzling, now What About Renovate?

So the gradle setup is good, even three ways to choose how to set the platform. Renovate also supports the project stack.

Here's a starter project, created via 'Launch', with Renovate enabled:
https://github.com/thriving-dev/micronaut-gradle-renovate-example-0

Info

Renovate is configured via renovate.json in the GitHub Repository.

Let's take a look at this screenshot of the Renovate dependency dashboard, Feb 2, 2024:

screenshot of the dependency dashboard of the example project, does show all dependencies tracked, missing the micronaut platform

We can find two micronaut dependencies, listed under build.gradle.kts.

  • io.micronaut.application 4.3.1
  • io.micronaut.aot 4.3.1

These are the two micronaut plugins used. They are tracked and updated by Renovate just fine.

The platform on the other hand, defined in gradle.properties that determines the actual version of micronaut-core and other modules, is not tracked.

micronautVersion=4.2.3

Cause

The explanation to the version not tracked is relatively simple.
...Renovate cannot resolve the packageName and datasource since there's no reference.

How to resolve?

When writing up this blog post I found three different solutions to the problem introduced.

Please continue with part 2!
-> 'Solution 1: Gradle Version Catalog + Dependency Hint in libs.versions.toml'.

Footnote: This blog post was written to work with Micronaut 4.x and Gradle 8.

Tip

If you're a maintainer or contributor to Open-Source Java libraries, take a look at thriving-dev/java-library-template introduced in September 2023. It ships with a ready to use renovate.json and setup guide.

CC BY-NC-SA 4.0 2022-2024 漏 Thriving.dev