Package io.quarkus.sbom
Class CoreSbomContributionConfig
java.lang.Object
io.quarkus.sbom.CoreSbomContributionConfig
Assembles the core Quarkus application SBOM contribution from Maven artifacts
and packaged files.
This class collects raw inputs — the ApplicationModel, main component identity,
additional component descriptors, and file system paths — and defers all processing
until toSbomContribution() is called. In particular, ComponentDescriptors
for the application model's dependencies are not created eagerly during configuration.
The main application component is resolved in the following priority order:
- If
setMainPurl(Purl)is set, a new component with that PURL is created (typically a generic PURL for native images or runner jars). - If
setMainArtifact(ResolvedDependency)is set, a Maven-PURL component is derived from it. - Otherwise the application artifact from the
ApplicationModelis used.
Only the core contribution designates a main application component. Extension-contributed
SbomContributions should not provide one.
Typical usage:
var contribution = new CoreSbomContributionConfig()
.setApplicationModel(appModel)
.setDistributionDirectory(buildDir)
.setMainPath(runnerJar)
.toSbomContribution();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a Maven dependency as a component.addComponent(ResolvedDependency dep, Path path) Adds a Maven dependency as a component with a file path that differs from the dependency's resolved path (e.g. after copying to a distribution directory).addComponent(ResolvedDependency dep, Path path, String pedigree) Adds a Maven dependency as a component with a custom file path and optional pedigree notes describing modifications (e.g. tree-shaken classes).addComponent(ComponentDescriptor component) Adds an extra component descriptor not derived from the application model.addFileDependency(Path parent, Path child) Declares that the component atparentpath depends on the component atchildpath.Sets the application model whose dependencies will be converted toComponentDescriptors whentoSbomContribution()is called.setDistributionDirectory(Path distributionDirectory) Sets the distribution directory.Sets the main component from a resolved Maven artifact.setMainDependencies(Collection<ArtifactCoords> dependencies) Sets the direct dependencies of the main component explicitly.setMainPath(Path runnerPath) Sets the file system path of the main runnable artifact (e.g. runner jar, native image).setMainPurl(Purl purl) Overrides the main component's PURL.setPedigrees(Map<ArtifactKey, String> pedigrees) Sets pedigree notes for application model dependencies, keyed by artifact.Converts this config into anSbomContribution, creating component descriptors from the application model, deduplicating by file path and Maven artifact key, resolving distribution paths, and producing the dependency graph.
-
Constructor Details
-
CoreSbomContributionConfig
public CoreSbomContributionConfig()
-
-
Method Details
-
setApplicationModel
Sets the application model whose dependencies will be converted toComponentDescriptors whentoSbomContribution()is called. The model's application artifact also serves as the default main component when neithersetMainPurl(io.quarkus.sbom.Purl)norsetMainArtifact(io.quarkus.maven.dependency.ResolvedDependency)is specified.- Parameters:
model- the resolved application model- Returns:
- this config
-
setMainArtifact
Sets the main component from a resolved Maven artifact. A Maven PURL and dependency list are derived from it automatically. Use this when the main component is a Maven artifact whose identity differs from the application model's application artifact, or when no application model is set.- Parameters:
dep- the resolved dependency representing the main artifact- Returns:
- this config
-
setMainPurl
Overrides the main component's PURL. Use this for non-Maven main components such as native images or runner jars that need a generic PURL instead of a Maven one.- Parameters:
purl- the PURL identifying the main component- Returns:
- this config
-
setMainDependencies
Sets the direct dependencies of the main component explicitly. These are used to mark components as top-level in the generated SBOM. If not set, the dependencies are obtained from the main artifact'sResolvedDependency.getDependencies().- Parameters:
dependencies- the main component's direct dependency coordinates- Returns:
- this config
-
setPedigrees
Sets pedigree notes for application model dependencies, keyed by artifact. The pedigree for each dependency is applied whentoSbomContribution()creates its component descriptor.- Parameters:
pedigrees- artifact-key-to-pedigree map, ornull- Returns:
- this config
-
setDistributionDirectory
Sets the distribution directory. When set, files in this directory that are not already registered as components are added with generic PURLs, and component distribution paths are resolved relative to this directory.- Parameters:
distributionDirectory- the build output directory- Returns:
- this config
-
setMainPath
Sets the file system path of the main runnable artifact (e.g. runner jar, native image). This path is recorded on theSbomContributionand also overrides the main component's file path for hash computation and distribution path resolution.- Parameters:
runnerPath- path to the main runnable artifact- Returns:
- this config
-
addComponent
Adds an extra component descriptor not derived from the application model. Use this for non-Maven components such as build-generated files that need a generic PURL.- Parameters:
component- the component descriptor- Returns:
- this config
-
addComponent
Adds a Maven dependency as a component. The Maven PURL, path, and scope are derived from the dependency.- Parameters:
dep- the resolved Maven dependency- Returns:
- this config
-
addComponent
Adds a Maven dependency as a component with a file path that differs from the dependency's resolved path (e.g. after copying to a distribution directory).- Parameters:
dep- the resolved Maven dependencypath- the actual file path of the component artifact- Returns:
- this config
-
addComponent
Adds a Maven dependency as a component with a custom file path and optional pedigree notes describing modifications (e.g. tree-shaken classes).- Parameters:
dep- the resolved Maven dependencypath- the actual file path, ornullto use the dependency's resolved pathpedigree- pedigree notes, ornull- Returns:
- this config
-
addFileDependency
Declares that the component atparentpath depends on the component atchildpath. Both paths must correspond to files in the distribution directory so that they can be resolved to components duringtoSbomContribution().- Parameters:
parent- file path of the parent componentchild- file path of the child component- Returns:
- this config
-
toSbomContribution
Converts this config into anSbomContribution, creating component descriptors from the application model, deduplicating by file path and Maven artifact key, resolving distribution paths, and producing the dependency graph.This is the only path that designates a main application component in the SBOM.
- Returns:
- an SbomContribution representing the core application manifest
-