Micronaut 5 Conventions

These plugins remove some of the boilerplate configuration in a multi-project Micronaut v5 repository.

Works well with the Docker Conventions plugin.

Requirements

Gradle

9.3 or later

Gradle daemon

Java 25, installed locally

Application runtime

Java 25

The Micronaut Gradle Plugin 5 is built for Java 25, so Gradle itself must run on Java 25. A Java toolchain does not cover this: it picks the JDK that compiles and runs your code, not the one Gradle runs on.

Pin the daemon JDK in gradle/gradle-daemon-jvm.properties, and Gradle starts the daemon on an installed Java 25 whatever JAVA_HOME points at:

gradle/gradle-daemon-jvm.properties
toolchainVersion=25

Gradle does not download it; install Java 25 yourself, for example with sdk install java 25.0.4-tem.

A dockerBaseImage property must name a Java 25 image. Without it, Micronaut uses eclipse-temurin:<java>-jre for the project’s target Java version, 25-jre when the build compiles for Java 25.

Configure Library

build.gradle
plugins {
    id 'java'
    id 'no.conta.micronaut-v5-library-conventions'
}

Configure Application

build.gradle
plugins {
    id 'no.conta.java-conventions'
    id 'no.conta.micronaut-v5-application-conventions'
    id 'no.conta.docker-conventions'
}

micronaut {
    runtime 'netty'
    testRuntime 'spock2'
}

dependencies {
    implementation 'io.micronaut.serde:micronaut-serde-jackson'
    runtimeOnly 'ch.qos.logback:logback-classic'
}

application {
    mainClass.set 'no.conta.App'
}
gradle.properties
# example file
micronautVersion=5.2.4
lombokVersion=1.18.48