How to use a common `Versions` object with `buildSrc` plugins?

The sample project is available here: and is a kotlin + spring boot project.

I want to have a “common gradle project” that i apply to my subprojects.
It is found at: buildSrc/src/main/kotlin/land/tbp/wwsc/tralala.gradle.kts and it applies multiple plugins, one of which is id("org.springframework.boot").

In order to set the versions of these plugins, i need to add the plugins as dependencies inside the file buildSrc/build.gradle.kts.

I have buildSrc/src/main/kotlin/land/tbp/wwsc/Versions.kt where i want to store all my versions. this also includes plugins.

I want to do this because the dependency implementation(platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion")) (here) must have the same version as the one of the plugin that is applied.

The problem is that i cannot access import land.tbp.wwsc.Versions.springBootVersion from buildSrc/build.gradle.kts, so what i need to do is duplicate the properties which store the versions inside buildSrc/build.gradle.kts as well, and whenever i have to update a version, i need to so that in 2 places.

  • buildSrc/build.gradle.kts -> springBootVersion
  • buildSrc/src/main/kotlin/land/tbp/wwsc/Versions.kt -> Versions.springBootVersion

Please see here:

My question is: is there a way to have the cake and eat it too?
Is there a way to use the object buildSrc/src/main/kotlin/land/tbp/wwsc/Versions.kt everywhere? Or is there an alternative which does not lead to code duplication?


Does anyone have advice or experience with common versioning in buildSrc?

I just put a version.txt file in my root directory then reference via

buildscript {
	def pluginVersion = file('../version.txt').text.trim()
	dependencies {
		classpath "$pluginVersion"

See here and here