If this question has been asked and answered, or that there is doc or an example, please forgive me. I have spent several hours looking for a solution here on stackoverflow and even more time in the gradle doc and haven't been able to make this work.
I have a spring boot project with a pretty standard maven layout. I am using gradle 2.4. here's the layout of the relevent files:
/gradle.properties
/build.gradle
/settings.gradle
/src/main/resources/application.yml
In gradle.properties
, I have defined the following properties:
name=Sample microservice
description=brief description of the service goes here
version=1.0.0-SNAPSHOT
In my application.yml file, I'd like to set corresponding spring properties to those same values. (I'd like to define them together in one place and use them in several places. Since version
is typically defined in gradle.properties, I want to cluster the rest there as well.)
I've tried the following line in application.yml, but things aren't working as hoped:
info.app.name: ${name}
info.app.description: ${description}
info.app.version: ${version}
(I also tried ${project.name}
, etc. That didn't work either.)
I ran gradlew properties
... the properties are listed with values as expected. However, when I run a build, the yaml file is copied into \build\resources\main
as expected, but the ${value}
tokens are not resolved.
I also included the following lines in build.gradle
file, but things remain unresolved.
processResources {
filesMatching('gradle.properties') { expand(project.properties) }
}
(My goal is to use the actuator /info
endpoint to provide the values of those properties to a service caller.)
Any suggestions or pointers to documentation that help would be greatly appreciated!