Multi-Project properties with Kotlin DSL


I’m looking for learning what the best practice is for storing dependency and plugin versions as Gradle properties in a multi-project build and having these properties available to all my subprojects.

I am using the Kotlin DSL for my build scripts.

For example I’d expect that I could define a property in my root project:

and be able to use this property anywhere throughout my multi-project build. I.e. in other build.gradle files. How ever I keep getting errors like:

Line 05: compile("com.graphql-java:graphql-java-servlet:$graphQlJavaVersion")
^ Unresolved reference: graphQlJavaVersion

How does every one else define versions once and use that version throughout the project? Could any one link me to some examples?

1 Like

So one solution (I hope there is a better solution) which works is:
springBootVersion = 2.0.4.RELEASE

build.gradle (root project)

val springBootVersion: String by project`
extra {

dependencies {
   compile("org.springframework.boot:spring-boot-starter-data-jpa:${rootProject.extra.get("springBootVersion") as String}")

This comes from the Kotlin DSL example project

Please note that spring-boot-starter-data-jpa has just been used as an example and is not part of the problem I’m trying to solve.