From 2ba2cfe23db4fb289f79b364ce24da846a54c2c0 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 15 Sep 2014 16:25:00 +0100 Subject: [PATCH] Document build-time property expansion using Gradle Closes gh-1540 --- .../asciidoc/production-ready-features.adoc | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 8772c345a06..f1594a5e530 100644 --- a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -195,9 +195,20 @@ exposed. For example, you could add the following to your `application.propertie info.app.version=1.0.0 ---- -If you are using Maven, you can automatically expand info properties from the Maven -project using resource filtering. In your `pom.xml` you have (inside the `` -element): + + +[[production-ready-application-info-automatic-expansion]] +==== Automatically expand info properties at build time +Rather than hardcoding some properties that are also specified in your project's +build configuration, you can automatically expand info properties using the +existing build configuration instead. This is possible in both Maven and Gradle. + + + +[[production-ready-application-info-automatic-expansion-maven]] +===== Automatic property expansion using Maven +You can automatically expand info properties from the Maven project using resource +filtering. In your `pom.xml` you have (inside the `` element): [source,xml,indent=0] ---- @@ -228,6 +239,29 @@ fallbacks if the Maven resource filtering has not been switched on for some reas +[[production-ready-application-info-automatic-expansion-gradle]] +===== Automatic property expansion using Gradle +You can automatically expand info properties from the Gradle project by configuring +the Java plugin's `processResources` task to do so: + +[source,groovy,indent=0] +---- +processResources { + expand(project.properties) +} +---- + +You can then refer to your Gradle project's properties via placeholders, e.g. + +[source,properties,indent=0] +---- + info.build.name=${name} + info.build.description=${description} + info.build.version=${version} +---- + + + [[production-ready-git-commit-information]] ==== Git commit information Another useful feature of the `info` endpoint is its ability to publish information