In my Gradle build (Kotlin) I'm using Micronaut's platform catalog to declare dependencies as static code as listed below.
// I use this way
implementation(mn.micronaut.serde.jackson)
// instead of that§
implementation("io.micronaut.serde:micronaut-serde-jackson")
Since the Micronaut's platform catalog needs to be declared in the settings.gradle.kts
plugins {
id("io.micronaut.platform.catalog") version "4.3.5"
}
As you probably noticed I have to hard code the Gradle plugin version number 4.3.5
in my settings.gradle.kts
but I'd rather like to use the Micronaut version from my gradle/libs.versions.toml
file.
[versions]
micronaut = "4.3.7"
micronautGradlePluginVersion = "4.3.5"
[plugins]
micronaut-application = { id = "io.micronaut.application", version.ref = "micronautGradlePluginVersion" }
micronaut-platform = { id = "io.micronaut.platform.catalog", version.ref = "micronautGradlePluginVersion" }
Unfortunately it seems that within the settings.gradle.kts
I don't have access to the as I have in a build.gradle.kts
file
// build.gradle.kts
plugins {
alias(libs.plugins.micronaut.platform)
}
Is there a way how I can make this working in my settings.gradle.kts
without having to hard code the version number or even use something equivalent to
// settings.gradle.kts
plugins {
alias(libs.plugins.micronaut.platform)
}
?
Unfortunately, this is not possible, as mentioned by a Gradle member in this GitHub issue regarding using version catalog accessors in a settings script:
Version catalogs can't be used before they have been evaluated, which happens during settings evaluation, which is AFTER evaluating settings plugins. So basically a chicken and egg problem; nothing we can do about it.
~ (Make version catalogs available in settings script's plugin block)
Which means that you'll have to manually declare the plugin versions like you're currently doing:
plugins {
id("io.micronaut.platform.catalog") version "4.3.5"
}