[[integrating-with-actuator]]
= Integrating with Actuator



[[integrating-with-actuator.build-info]]
== Generating Build Information

Spring Boot Actuator's `info` endpoint automatically publishes information about your build in the presence of a `META-INF/build-info.properties` file.
A {apiref-gradle-plugin-boot-build-info}[`BuildInfo`] task is provided to generate this file.
The easiest way to use the task is through the plugin's DSL:

[tabs]
======
Groovy::
+
[source,groovy,indent=0,subs="verbatim,attributes"]
----
include::example$integrating-with-actuator/build-info-basic.gradle[tags=build-info]
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,attributes"]
----
include::example$integrating-with-actuator/build-info-basic.gradle.kts[tags=build-info]
----
======

This will configure a {apiref-gradle-plugin-boot-build-info}[`BuildInfo`] task named `bootBuildInfo` and, if it exists, make the Java plugin's `classes` task depend upon it.
The task's destination directory will be `META-INF` in the output directory of the main source set's resources (typically `build/resources/main`).

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

| `build.group`
| The group of the project

| `build.name`
| The name of the project

| `build.version`
| The version of the project

| `build.time`
| The time at which the project is being built

|===

The properties can be customized using the DSL:

[tabs]
======
Groovy::
+
[source,groovy,indent=0,subs="verbatim,attributes"]
----
include::example$integrating-with-actuator/build-info-custom-values.gradle[tags=custom-values]
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,attributes"]
----
include::example$integrating-with-actuator/build-info-custom-values.gradle.kts[tags=custom-values]
----
======

To exclude any of the default properties from the generated build information, add its name to the excludes.
For example, the `time` property can be excluded as follows:

[tabs]
======
Groovy::
+
[source,groovy,indent=0,subs="verbatim,attributes"]
----
include::example$integrating-with-actuator/build-info-exclude-time.gradle[tags=exclude-time]
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,attributes"]
----
include::example$integrating-with-actuator/build-info-exclude-time.gradle.kts[tags=exclude-time]
----
======

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.
Another side-effect is that the task's output will always change and, therefore, the build will not be truly repeatable.
If you value build performance or repeatability more highly than the accuracy of the `build.time` property, exclude the `time` property as shown in the preceding example.

Additional properties can also be added to the build information:

[tabs]
======
Groovy::
+
[source,groovy,indent=0,subs="verbatim,attributes"]
----
include::example$integrating-with-actuator/build-info-additional.gradle[tags=additional]
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,attributes"]
----
include::example$integrating-with-actuator/build-info-additional.gradle.kts[tags=additional]
----
======

An additional property's value can be computed lazily by using a `Provider`.
