While in Gradle we usually tend to use variable like jacksonVersion
, in Spring Boot application we tend to use jackson.version
to override the default version. This kind of variable name is defined via ext['jackson.version'] = '2.7.3'
for example.
Since we can’t write compile("foo:bar:${jackson.version}")
because of the dot, I tried compile("foo:bar:${ext['jackson.version']}")
but while String interpolation works if I write println "${ext['jackson.version']}"
, if I try to write dependencies { compile("foo:bar:${jackson.version}") }
it fails with the following error: Error:(55, 0) Cannot get property 'jackson.version' on extra properties extension as it does not exist
.
To make it easier to reproduce, String interpolation fails at dependency
level:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE'
}
}
apply plugin: 'spring-boot'
repositories {
jcenter()
}
ext['jackson.version'] = '2.7.3'
println ext['jackson.version']
println "${ext['jackson.version']}"
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile "com.fasterxml.jackson.module:jackson-module-kotlin:${ext['jackson.version']}"
}
While it works at dependencyManagement level:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE'
}
}
apply plugin: 'spring-boot'
repositories {
jcenter()
}
ext['jackson.version'] = '2.7.3'
dependencyManagement {
dependencies {
dependency "com.fasterxml.jackson.module:jackson-module-kotlin:${ext['jackson.version']}"
}
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'com.fasterxml.jackson.module:jackson-module-kotlin'
}
Could it be possible to make it works at dependency
level like in other places?