How to Resolve Conflicts in Micronaut 1.x and 2.x Library Versions in Gradle

Micronaut 2.x version has changed the Maven coordinates for many libraries that crate the Micronaut ecosystem. The complete list can be found here:

Although it makes no difference if the Micronaut version for all your application is aligned, it causes issues if you need to support both versions of the framework. If you are using Gradle you can benefit from the advanced resolution rules available:

Let's pretend that we are using library which transitively depends on Micronaut Views Handlebar and was created with Micronaut 1.x. In the project using Micronaut 2.x or later, you have to declare the following dependency mapping:

Because the resolution is only triggered when there is a conflict, you need to add the dependency to the new coordinates into the project's build file directly:

Now all the dependencies using the old coordinates are replaced with the new ones.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store