Skip to content

Add jarmode tools command to print / export the SBOM - #51505

Merged
mhalbritter merged 2 commits into
spring-projects:mainfrom
xxxxxxjun:add-jarmode-tools-sbom-command
Sep 2, 2026
Merged

mhalbritter merged 2 commits into
spring-projects:mainfrom
xxxxxxjun:add-jarmode-tools-sbom-command

Conversation

@xxxxxxjun

@xxxxxxjun xxxxxxjun commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Adds an sbom command to the tools jar mode. Given an uber jar or war, it prints the packaged SBOM. Reading that SBOM currently means starting the application and calling the actuator's sbom endpoint.

To find the SBOM, the command reads the Sbom-Location manifest attribute and uses the value as-is: the Gradle plugin already writes the WEB-INF/classes/ prefix for wars. The entry at that location is written byte for byte to the console, or to the file given by --destination. Because the output is meant to be piped elsewhere, the command exits with a non-zero code if it can't write to the console.

Command failures in the tools jar mode print as a stack trace instead of Error: <message>. That is a pre-existing bug, now fixed separately in #51540 against 4.0.x.

Closes #45954

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 29, 2026
@xxxxxxjun
xxxxxxjun force-pushed the add-jarmode-tools-sbom-command branch from 94897a0 to 74ccdfb Compare August 29, 2026 18:25
@mhalbritter mhalbritter self-assigned this Sep 1, 2026
@mhalbritter mhalbritter added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 1, 2026
@mhalbritter mhalbritter added this to the 4.2.x milestone Sep 1, 2026
@mhalbritter mhalbritter changed the title Add jarmode tools SBOM command Add jarmode tools command to print / export the SBOM Sep 1, 2026
@mhalbritter

Copy link
Copy Markdown
Contributor

Hello @xxxxxxjun , thanks for the PR!

It also changes what extract and list-layers print when they fail, so I'm happy to move it to its own PR if you'd prefer.

That would be very welcome. Please target 4.0.x as the branch, we'll do that as a bugfix. Besides that, I did a review, and it looks good to merge. Please move the commit which fixes
JarModeErrorException into its own PR, then I can merge them both.

Much appreciated!

@xxxxxxjun

Copy link
Copy Markdown
Contributor Author

Done – split out as #51540 against 4.0.x.

The test there uses list-layers rather than sbom, since that branch doesn't have the new command. This PR now only adds sbom.

xxxxxxjun and others added 2 commits September 2, 2026 16:26
Add an 'sbom' command to the tools jar mode which prints the SBOM
packaged in an uber jar or war. The SBOM is located using the
Sbom-Location manifest attribute and its bytes are copied verbatim to
the console, or to the file given by --destination.

See spring-projectsgh-51505

Signed-off-by: Hyeongjun Cho <ryuu.public@gmail.com>
@mhalbritter
mhalbritter force-pushed the add-jarmode-tools-sbom-command branch from 28ecd8f to e5a24ba Compare September 2, 2026 14:48
@mhalbritter
mhalbritter merged commit 87cacda into spring-projects:main Sep 2, 2026
3 of 4 checks passed
@mhalbritter mhalbritter modified the milestones: 4.2.x, 4.2.0-M2 Sep 2, 2026
@mhalbritter

Copy link
Copy Markdown
Contributor

Thanks @xxxxxxjun !

@xxxxxxjun
xxxxxxjun deleted the add-jarmode-tools-sbom-command branch September 2, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add jarmode tools command to print / export the SBOM

3 participants