Class SBOMGenerator
- java.lang.Object
-
- org.graalvm.buildtools.maven.sbom.SBOMGenerator
-
public final class SBOMGenerator extends java.lang.ObjectGenerates a Software Bill of Materials (SBOM) that is augmented and refined by Native Image. This feature is only supported in Oracle GraalVM for JDKrequiredNativeImageVersionor later.Approach: 1. The cyclonedx-maven-plugin creates a baseline SBOM. 2. The components of the baseline SBOM (referred to as the "base" SBOM) are updated with additional metadata, most importantly being the set of package names associated with the component (see
SBOMGenerator.AddedComponentFieldsfor all additional metadata). 3. The SBOM is stored at a known location. 4. Native Image processes the SBOM and removes unreachable components and unnecessary dependencies.Creating the package-name-to-component mapping in the context of Native Image, without the knowledge known at the plugin build-time is difficult, which was the primary motivation for realizing this approach.
Benefits: * Great Baseline: Produces an industry-standard SBOM at minimum. * Enhanced Accuracy: Native Image augments and refines the SBOM, potentially significantly improving its accuracy.
-
-
Field Summary
Fields Modifier and Type Field Description static intrequiredNativeImageVersionstatic java.lang.StringSBOM_FILENAME
-
Constructor Summary
Constructors Constructor Description SBOMGenerator(org.apache.maven.project.MavenProject mavenProject, org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.BuildPluginManager pluginManager, org.eclipse.aether.RepositorySystem repositorySystem, java.lang.String mainClass, org.codehaus.plexus.logging.Logger logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancheckAugmentedSBOMSupportedByJDKVersion(int detectedJdkVersion, boolean throwErrorIfNotSupported)Checks if the JDK version supports augmented SBOMs.voidgenerate()Generates an SBOM that will be further augmented by Native Image.
-
-
-
Field Detail
-
requiredNativeImageVersion
public static final int requiredNativeImageVersion
- See Also:
- Constant Field Values
-
SBOM_FILENAME
public static final java.lang.String SBOM_FILENAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SBOMGenerator
public SBOMGenerator(org.apache.maven.project.MavenProject mavenProject, org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.BuildPluginManager pluginManager, org.eclipse.aether.RepositorySystem repositorySystem, java.lang.String mainClass, org.codehaus.plexus.logging.Logger logger)
-
-
Method Detail
-
checkAugmentedSBOMSupportedByJDKVersion
public static boolean checkAugmentedSBOMSupportedByJDKVersion(int detectedJdkVersion, boolean throwErrorIfNotSupported) throws java.lang.IllegalArgumentExceptionChecks if the JDK version supports augmented SBOMs.- Parameters:
detectedJdkVersion- the JDK version used.throwErrorIfNotSupported- if true, then an error is thrown if the check failed.- Returns:
- true if the JDK version supports the flag, otherwise false (if throwErrorIfNotSupported is false).
- Throws:
java.lang.IllegalArgumentException- when throwErrorIfNotSupported is true and the version check failed.
-
generate
public void generate() throws org.apache.maven.plugin.MojoExecutionExceptionGenerates an SBOM that will be further augmented by Native Image. The SBOM is stored in the build directory.- Throws:
org.apache.maven.plugin.MojoExecutionException- if SBOM creation fails.
-
-