Allow build info properties to be excluded

Update Maven and Gradle plugins to allow build info properties to be
excluded.

Prior to this commit, the `BuildPropertiesWriter` would fail with an
NPE if the group, artifact, name or version properties were `null`.

This was specifically problematic with the Gradle plugin, since its
DSL allows `null` properties which would either be passed to the writer
or, in the case of `artifact`, converted into a string value of
"unspecified".

See gh-27412
This commit is contained in:
Vedran Pavic
2021-07-16 21:57:57 +02:00
committed by Phillip Webb
parent 2034ad4827
commit ea9faf8690
13 changed files with 355 additions and 26 deletions

View File

@@ -30,8 +30,7 @@ By default, the generated build information is derived from the project:
| Property | Default value
| `build.artifact`
| The base name of the `bootJar` or `bootWar` task, or `unspecified` if no such task
exists
| The base name of the `bootJar` or `bootWar` task
| `build.group`
| The group of the project
@@ -61,6 +60,8 @@ include::../gradle/integrating-with-actuator/build-info-custom-values.gradle[tag
include::../gradle/integrating-with-actuator/build-info-custom-values.gradle.kts[tags=custom-values]
----
NOTE: To omit any of the default properties from the generated build information, set its value to `null`.
The default value for `build.time` is the instant at which the project is being built.
A side-effect of this is that the task will never be up-to-date.
As a result, builds will take longer as more tasks, including the project's tests, will have to be executed.