Skip to content

Commit 2ba2cfe

Browse files
committed
Document build-time property expansion using Gradle
Closes gh-1540
1 parent 3c815f4 commit 2ba2cfe

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

spring-boot-docs/src/main/asciidoc/production-ready-features.adoc

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,20 @@ exposed. For example, you could add the following to your `application.propertie
195195
info.app.version=1.0.0
196196
----
197197

198-
If you are using Maven, you can automatically expand info properties from the Maven
199-
project using resource filtering. In your `pom.xml` you have (inside the `<build/>`
200-
element):
198+
199+
200+
[[production-ready-application-info-automatic-expansion]]
201+
==== Automatically expand info properties at build time
202+
Rather than hardcoding some properties that are also specified in your project's
203+
build configuration, you can automatically expand info properties using the
204+
existing build configuration instead. This is possible in both Maven and Gradle.
205+
206+
207+
208+
[[production-ready-application-info-automatic-expansion-maven]]
209+
===== Automatic property expansion using Maven
210+
You can automatically expand info properties from the Maven project using resource
211+
filtering. In your `pom.xml` you have (inside the `<build/>` element):
201212

202213
[source,xml,indent=0]
203214
----
@@ -228,6 +239,29 @@ fallbacks if the Maven resource filtering has not been switched on for some reas
228239

229240

230241

242+
[[production-ready-application-info-automatic-expansion-gradle]]
243+
===== Automatic property expansion using Gradle
244+
You can automatically expand info properties from the Gradle project by configuring
245+
the Java plugin's `processResources` task to do so:
246+
247+
[source,groovy,indent=0]
248+
----
249+
processResources {
250+
expand(project.properties)
251+
}
252+
----
253+
254+
You can then refer to your Gradle project's properties via placeholders, e.g.
255+
256+
[source,properties,indent=0]
257+
----
258+
info.build.name=${name}
259+
info.build.description=${description}
260+
info.build.version=${version}
261+
----
262+
263+
264+
231265
[[production-ready-git-commit-information]]
232266
==== Git commit information
233267
Another useful feature of the `info` endpoint is its ability to publish information

0 commit comments

Comments
 (0)