dependencyManagement.importedProperties is empty
Closed this issue · 3 comments
According to Accessing Properties from Imported Boms, version properties can be accessed like so:
dependencyManagement.importedProperties["spring.version"]
However, dependencyManagement.importedProperties
is empty.
plugins {
id("io.spring.dependency-management") version "1.1.0"
}
println(dependencyManagement.importedProperties)
println(dependencyManagement.importedProperties["spring.version"])
Output:
{}
null
With the snippet above, I would not expect there to be any imported properties as no boms have been imported. Do you see the problem when a bom is imported?
You're right:
plugins {
id("io.spring.dependency-management") version "1.1.0"
}
dependencyManagement {
imports {
mavenBom("io.spring.platform:platform-bom:Cairo-SR8")
// This does not specify spring.version
// mavenBom("org.springframework.boot:spring-boot-dependencies:3.0.1")
}
}
println(dependencyManagement.importedProperties["spring.version"])
5.0.13.RELEASE
But this shouldn't be necessary, should it?
When the io.spring.dependency-management plugin is applied to a project, the Spring Boot plugin will automatically import the spring-boot-dependencies bom.
And if we needed to import the Bom explicitly, how can we make sure we import a Version that is compatible with io.spring.dependency-management
?
You haven't applied the Spring Boot plugin so how it reacts to other plugins being applied does not matter. If you apply both the Spring Boot plugin and the dependency management plugin, Boot's plugin will automatically import the spring-boot-dependencies
bom and its imported properties will be available:
plugins {
id("io.spring.dependency-management") version "1.1.0"
id("org.springframework.boot") version "3.0.1"
}
repositories {
mavenCentral()
}
println(dependencyManagement.importedProperties["spring-framework.version"])
The above will output 6.0.3
.
And if we needed to import the Bom explicitly, how can we make sure we import a Version that is compatible with
io.spring.dependency-management
?
The io.spring.dependency-management
plugin should support any valid Maven bom.