Integrating with Actuator

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 BuildInfo task is provided to generate this file. The easiest way to use the task is through the plugin’s DSL:spring-doc.cn

springBoot {
	buildInfo()
}
springBoot {
	buildInfo()
}

This will configure a 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).spring-doc.cn

By default, the generated build information is derived from the project:spring-doc.cn

Property Default value

build.artifactspring-doc.cn

The base name of the bootJar or bootWar taskspring-doc.cn

build.groupspring-doc.cn

The group of the projectspring-doc.cn

build.namespring-doc.cn

The name of the projectspring-doc.cn

build.versionspring-doc.cn

The version of the projectspring-doc.cn

build.timespring-doc.cn

The time at which the project is being builtspring-doc.cn

The properties can be customized using the DSL:spring-doc.cn

springBoot {
	buildInfo {
		properties {
			artifact = 'example-app'
			version = '1.2.3'
			group = 'com.example'
			name = 'Example application'
		}
	}
}
springBoot {
	buildInfo {
		properties {
			artifact.set("example-app")
			version.set("1.2.3")
			group.set("com.example")
			name.set("Example application")
		}
	}
}

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:spring-doc.cn

springBoot {
	buildInfo {
		excludes = ['time']
	}
}
springBoot {
	buildInfo {
		excludes.set(setOf("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.spring-doc.cn

Additional properties can also be added to the build information:spring-doc.cn

springBoot {
	buildInfo {
		properties {
			additional = [
				'a': 'alpha',
				'b': 'bravo'
			]
		}
	}
}
springBoot {
	buildInfo {
		properties {
			additional.set(mapOf(
				"a" to "alpha",
				"b" to "bravo"
			))
		}
	}
}

An additional property’s value can be computed lazily by using a Provider.spring-doc.cn