Matthew Planchant
03/18/2025, 12:53 PMsettings.gradle.kts, I'm using the following to get the value of myVersion from gradle.properties .
val myVersion: String by settings
How do I do the same from buildSrc/settings.gradle.kts ?Vampire
03/18/2025, 1:02 PMbuildSrc is an own build that does not use the same gradle.properties file and the properties are not propagated to the buildSrc build as it is an own build that "just happens" to build before your main build.
If you want to have a central place to define versions, I recommend you use a version catalog instead, you can then in the buildSrc build to use the same version catalog as the main build.Matthew Planchant
03/18/2025, 1:53 PMmicronautVersion) is used as follows in the settings.gradle.kts
val micronautVersion: String by settings
dependencyResolutionManagement {
repositories {
mavenCentral()
}
versionCatalogs {
create("mn") {
from("io.micronaut.platform:micronaut-platform:${micronautVersion}")
}
}
}Vampire
03/18/2025, 1:55 PMVampire
03/18/2025, 1:55 PMbuildSrc build?Matthew Planchant
03/18/2025, 1:56 PMVampire
03/18/2025, 1:58 PMMatthew Planchant
03/18/2025, 2:04 PMdependencies {
implementation(mn.micronaut.serde.jackson)
...
}
in my convention plugin.Vampire
03/18/2025, 2:22 PMbuildSrc settings script, that is for the buildSrc build scripts, not for the things you build inside the project like conventions plugins.
For that you would need my hack-around, and even with that, it would not work for plugins but only for normal dependencies.
Maybe you should consider using the string-y VersionCatalogsExtension in your convention plugins, so something like versionCatalogs.findCatalog("mn").findLibrary("micronaut-serde-jackson") or what the syntax was. Then you also do not need the version catalog in the buildSrc build.Vampire
03/18/2025, 2:23 PMbuildSrc/build.gradle.kts on the other hand you could use them, but maybe you should just duplicate the mn version to both gradle.properties, the main build one's and the buildSrc build one'sMatthew Planchant
03/18/2025, 2:38 PM