I'm trying to set up my build.gradle file to have a one-stop-shop for version numbers. I've been able to use string replacement in the dependencies{} block but haven't had any luck doing the same to the plugins{} block. Currently it looks like this:
buildscript {
ext {
ver = [
springBoot: "2.1.2.RELEASE",
]
}
}
plugins {
id "org.springframework.boot" version "2.1.2.RELEASE"
}
dependencies {
compile "org.springframework.boot:spring-boot-gradle-plugin:${ver.springBoot}"
compile "org.springframework.boot:spring-boot-starter-web:${ver.springBoot}"
compile "org.springframework.boot:spring-boot-starter-actuator:${ver.springBoot}"
}
If I change the plugins block to this (or several similar variants I've tried):
plugins {
id "org.springframework.boot" version "${ver.springBoot}"
}
Then I get this error:
Could not compile build file 'C:\GitRepos\groovy-rest-template\project\build.gradle'.
> startup failed:
build file 'C:\GitRepos\groovy-rest-template\project\build.gradle': 59: argument list must be exactly 1 literal non empty string
I am not married to using the buildscript{ext{}} setup, that is just the first system I found that works 90% of the way for us. I haven't been able to find much info on this in general and don't even know if it is possible to do string replacement in the plugins block. Solutions also don't have to be constrained to just the build.gradle file