Repository navigation
Write a mapped license in the CycloneDX license wrapper - #17207
Merged
Merged
Conversation
Each entry of a component's licenses in a CycloneDX BOM holds its
license under the key license. pickLicense returned a license it took
from LICENSE_MAPPING without that key, as {id, url} or {name, url}, so
the SBOM of every module with such a dependency, such as sitemesh,
jline or jzlib, failed validation against the CycloneDX 1.6 schema.
cyclonedx-core-java's parser read the entry anyway.
The new SbomPluginSpec builds the SBOM of a library with a dependency
mapped to a license id, one mapped to a license name and one with a
preferred license, and validates it against the schema.
✅ All tests passed ✅🏷️ Commit: 6586c94 Learn more about TestLens at testlens.app/docs. |
jamesfredley
left a comment
Contributor
There was a problem hiding this comment.
The changes look good.
jdaugherty
approved these changes
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
In a CycloneDX BOM, each entry of a component's
licensesholds its license under the keylicense. WhenSbomPluginoverrides a dependency's license fromLICENSE_MAPPING,pickLicensereturned the license block itself,{id, url}or{name, url}, without that key. So the SBOM of every module with such a dependency fails validation against the CycloneDX 1.6 schema:cyclonedx-core-java's parser reads the entry anyway, which is why the build never noticed. The SBOMs in released jars have it, for example
grails-layout7.0.17 (sitemesh), andgrails-layoutandgrails-shell-cli8.0.0 (sitemesh, jline).It was found in the review of #17203, which fixes it on 8.0.x along with the CycloneDX update. This PR fixes the 7.x branches.
The fix
pickLicensereturns[license: licenseBlock]for a mapped license. A license that isn't mapped already came back as the entry CycloneDX wrote, with the key.Tests
SbomPluginSpecis new on 7.0.x. Its TestKit feature builds the SBOM of a library with three dependencies from a local repository:BSD-3-Clause;It validates the SBOM against the CycloneDX 1.6 schema with cyclonedx-core-java's
JsonParser, and checks each license entry. Without the fix, the schema check fails.On JDK 17.0.18,
:build-logic:checkinbuild-logicruns 17 tests with 0 failures.I also regenerated all 130 SBOMs of the root, grails-gradle and grails-forge builds, with
cyclonedxBom --rerun --no-build-cache, and validated each against the CycloneDX 1.6 schema:The only difference between the two sets is the added
licensekey, on 31 entries for 11 dependencies: sitemesh, jline 2 and 3, antlr4-runtime, org.json, liquibase-hibernate5, the three Bouncy Castle modules and the two coherence BOMs.Merging up
SbomPluginis the same as 7.0.x's.SbomPluginmerges cleanly, whether Update the CycloneDX Gradle plugin to 3.6.1 #17203 is merged first or not. After Update the CycloneDX Gradle plugin to 3.6.1 #17203 the merge leaves it unchanged, since Update the CycloneDX Gradle plugin to 3.6.1 #17203 makes the same fix.SbomPluginSpecconflicts (add/add), because 8.0.x has its own spec. Keep 8.0.x's file and add this feature to it, with the task renamed tocyclonedxDirectBomand the imports it needs. I tried that resolution on 8.0.x as it is now and on Update the CycloneDX Gradle plugin to 3.6.1 #17203's head, andSbomPluginSpecpasses on both, with 7 and 18 tests.Tests on 7.0.x run only with the
run cilabel, which this PR has.