Streamline Micronaut + Gradle Updates with Renovate (4/4)
Series: Automated Dependency Updates for Micronaut + Gradle with Renovate
TLDR: Renovate cannot automatically update Micronaut dependencies for gradle projects created via 'Launch' or CLI. The final and best solution uses a Renovate custom regex manager.
Problem Recap
As covered in detail in the first post of this series
Renovate cannot resolve the packageName and datasource from the gradle.properties
file.
Solution 3 馃
The final solution does not require any changes to the Micronaut starter project and is entirely solved through Renovate config.
Renovate is very flexible. It's based on a modular architecture, and is extensible to the point that you can even contribute your own modules, if you want.
Further, the concept of presets allows you to start with good default settings, share and re-use configuration.
Finally, an advanced way to extend Renovate is via customManagers
.
With the regex manager you can configure Renovate, so it finds dependencies that are not detected by its other built-in package managers.
Great, that's actually exactly what we need!
Long story short, here's a customManager that defines the datasource, depName and packageName for */gradle.properties
files of your project, that contains a line of text micronautVersion=x.y.z
, matched by a regular expression.
This customManager is to be added to the renovate.json
in your project:
"customManagers": [
{
"customType": "regex",
"datasourceTemplate": "maven",
"depNameTemplate": "micronaut",
"packageNameTemplate": "io.micronaut.platform:micronaut-platform",
"fileMatch": ["(^|/)gradle\\.properties"],
"matchStrings": [
"micronautVersion=(?<currentValue>[\\w+\\.\\-]*)"
]
}
]
=> Et Voil脿!
Example
Again, here's an adjusted starter project, originally created via 'Launch', with Renovate enabled:
https://github.com/thriving-dev/micronaut-gradle-renovate-example-3
The project is automatically kept up-to-date for minor and patch version updates, with automerge enabled.
- You can see the maven package
io.micronaut.platform:micronaut-platform 4.x.x
tracked in the dependency dashboard (in the newregex
collection). - The closed Renovate bot PRs and commit history proofs everything is working as it should.
Summary
- Add the customManager introduced above to
renovate.json
We Have a Winner 馃
As the author, I get to decide 馃樇.
For me this third solution clearly takes first place with a wide margin.
Disagree? Leave a comment below!!
Next?
There's actually a bonus post under way! (to be released some time soon... so stay tuned!)
Footnote: This blog post was written to work with Micronaut 4.x and Gradle 8.
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.