Previously in Spring Boot 1.x, I wrote a Gradle task to copy the jar's build version to the application's application.yml
and replaced a given property by regex, e.g. info.build.version: 0.0.1
Migrating to Spring Boot 2.0, I realise there's the io.spring.dependency-management
plugin allowing me to define the buildInfo
task:
springBoot {
buildInfo()
}
This works and successfully displays the same information when accessing the /info
actuator.
Now I would like to use the generated build.version
in META-INF/build-info.properties
in two use-cases:
- Display the version in SwaggerUI
- Include the version in each log line
Previously, it was enough to access the property like this: @Value("${info.build.version:undefined}") String buildVersion
or in logback-spring.xml
:
<springProperty scope="context" name="applicationVersion" source="info.build.version"/>
Unfortunately, both accessors don't work anymore, even if I replace info.build.version
with build.version
(as I would expect it to work).
I believe including the version in logback is just a small step away from accessing the property through the @Value
annotation, so that's the core of my question:
How can I access the generated build.version
in META-INF/build-info.properties
through @Value
?
I also tried adding the task
processResources {
filesMatching('build-info.properties') {
expand(project.properties)
}
}
as suggested in https://stackoverflow.com/a/42051412/3105453 but that doesn't seem to have any effect.