Search code examples
gradlekotlingradle-kotlin-dsl

Override spring boot dependency version with gradle kotlin-dsl


SpringBoot comes with a lot of dependencies plus default versions for them. In groovy-gradle, such dependency versions can be overridden with:

ext['mockito.version'] = '1.7.5'

But this doesn't work for the kotlin-dsl. I tried:

val mockito by extra { "2.12.0" }
val mockito.version by extra { "2.12.0" }
val `mockito.version` by extra { "2.12.0" }

The latter two, don't compile, the first one, isn't doing the job.

How can the version be overridden within the kotlin file (I don't want to create a separate properties file if it is somehow possible).


Solution

  • Try extra["mockito.version"] = "1.7.5"