spring-projects/spring-boot · error · MojoFailureException

Failed to generate build-info.properties. {}

Error message

Failed to generate build-info.properties. {}

What it means

Thrown by BuildInfoMojo.execute as a MojoFailureException when BuildPropertiesWriter throws NullAdditionalPropertyValueException — i.e. an entry in <additionalProperties> has a null value (or a value that resolves to null) and cannot be written to build-info.properties. The message is the concatenation of the static prefix and the exception's message (the original error message is preserved in the {}-equivalent suffix). This is a configuration error: Maven plugin parameters do not allow null String values normally, but property interpolation or programmatic configuration can produce them.

Source

Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java:128

	@Inject
	public BuildInfoMojo(BuildContext buildContext) {
		this.buildContext = buildContext;
	}

	@Override
	public void execute() throws MojoExecutionException, MojoFailureException {
		if (this.skip) {
			getLog().debug("skipping build-info as per configuration.");
			return;
		}
		try {
			ProjectDetails details = getProjectDetails();
			new BuildPropertiesWriter(this.outputFile).writeBuildProperties(details);
			this.buildContext.refresh(this.outputFile);
		}
		catch (NullAdditionalPropertyValueException ex) {
			throw new MojoFailureException("Failed to generate build-info.properties. " + ex.getMessage(), ex);
		}
		catch (Exception ex) {
			throw new MojoExecutionException(ex.getMessage(), ex);
		}
	}

	private ProjectDetails getProjectDetails() {
		String group = getIfNotExcluded("group", this.project.getGroupId());
		String artifact = getIfNotExcluded("artifact", this.project.getArtifactId());
		String version = getIfNotExcluded("version", this.project.getVersion());
		String name = getIfNotExcluded("name", this.project.getName());
		Instant time = getIfNotExcluded("time", getBuildTime());
		Map<String, String> additionalProperties = applyExclusions(this.additionalProperties);
		return new ProjectDetails(group, artifact, version, name, time, additionalProperties);
	}

	private <T> @Nullable T getIfNotExcluded(String name, @Nullable T value) {
		return (this.excludeInfoProperties == null || !this.excludeInfoProperties.contains(name)) ? value : null;

View on GitHub (pinned to 5b2dbdbb8b)

Solutions

  1. Set a default value for the referenced property, e.g. ${git.commit.id:unknown}.
  2. Ensure any upstream plugin (git-commit-id-maven-plugin) that supplies the property runs before the build-info goal.
  3. Remove the offending entry from <additionalProperties> if the value is genuinely optional, or exclude it via excludeInfoProperties.
  4. Run with -X to see which additional property produced the NullAdditionalPropertyValueException.

Example fix

// before
<additionalProperties>
  <build.commit>${git.commit.id}</build.commit>
</additionalProperties>
// after — default value
<additionalProperties>
  <build.commit>${git.commit.id:unknown}</build.commit>
</additionalProperties>
Defensive patterns

Strategy: validation

Validate before calling

// Verify additional properties resolve to non-null before build-info
import java.util.Map;

void assertNoNullValues(Map<String,String> additional, java.util.Properties props) {
    for (var e : additional.entrySet()) {
        String v = e.getValue();
        if (v == null || (v.startsWith("${") && props.getProperty(strip(v))) == null) {
            throw new IllegalArgumentException("additionalProperty '" + e.getKey() + "' resolves to null");
        }
    }
}

Prevention

When it happens

Trigger: Declaring <additionalProperties><build.commit>${git.commit.id}</build.commit></additionalProperties> when the git.commit.id property is not defined and Maven leaves the literal or returns null; using a CI-injected property that was never set; a flattened POM or filtering step strips the value.

Common situations: Integrating git-commit-id-plugin properties that are not yet available at GENERATE_RESOURCES; referencing a property that only exists on certain CI branches; misspelling a property name in additionalProperties; resource filtering replacing the value with null.

Related errors


AI-assisted analysis of spring-projects/spring-boot@5b2dbdbb8b (2026-08-04). Data as JSON: /data/errors/79f9f805b7f3a770.json. Report an issue: GitHub.