Package org.spdx.maven.utils
Class SpdxV3DocumentBuilder
java.lang.Object
org.spdx.maven.utils.AbstractDocumentBuilder
org.spdx.maven.utils.SpdxV3DocumentBuilder
Builder for SPDX Spec version 3 SBOMs
- Author:
- Gary O'Neall
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.spdx.library.model.v3_0_1.core.CreationInfo
protected List<org.spdx.library.model.v3_0_1.core.DictionaryEntry>
Holds a mapping of IDs to URIs for any custom licenses defined outside the spdxDocprotected SpdxV3LicenseManager
protected org.spdx.library.model.v3_0_1.software.SpdxPackage
protected org.spdx.library.model.v3_0_1.software.Sbom
protected org.spdx.library.model.v3_0_1.core.SpdxDocument
Fields inherited from class org.spdx.maven.utils.AbstractDocumentBuilder
copyManager, format, generatePurls, modelStore, NULL_SHA1, outputFormatEnum, project, spdxFile, UNSPECIFIED
-
Constructor Summary
ConstructorsConstructorDescriptionSpdxV3DocumentBuilder
(org.apache.maven.project.MavenProject mavenProject, boolean generatePurls, File spdxFile, URI namespaceUri, OutputFormat outputFormatEnum) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNonStandardLicenses
(NonStandardLicense[] nonStandardLicenses) void
collectSpdxFileInformation
(List<org.apache.maven.shared.model.fileset.FileSet> sources, String baseDir, SpdxDefaultFileInformation defaultFileInformation, HashMap<String, SpdxDefaultFileInformation> pathSpecificInformation, Set<String> checksumAlgorithms) Collect information at the file level, fill in the SPDX documentvoid
fillSpdxDocumentInformation
(SpdxProjectInformation projectInformation) org.spdx.core.CoreModelObject
org.spdx.library.model.v3_0_1.core.SpdxDocument
mavenLicenseListToSpdxLicenseExpression
(List<org.apache.maven.model.License> mavenLicenses) void
Saves the SPDX document to the fileverify()
Verifies the top level document
-
Field Details
-
creationInfo
protected org.spdx.library.model.v3_0_1.core.CreationInfo creationInfo -
sbom
protected org.spdx.library.model.v3_0_1.software.Sbom sbom -
spdxDoc
protected org.spdx.library.model.v3_0_1.core.SpdxDocument spdxDoc -
projectPackage
protected org.spdx.library.model.v3_0_1.software.SpdxPackage projectPackage -
licenseManager
-
customIdToUri
Holds a mapping of IDs to URIs for any custom licenses defined outside the spdxDoc
-
-
Constructor Details
-
SpdxV3DocumentBuilder
public SpdxV3DocumentBuilder(org.apache.maven.project.MavenProject mavenProject, boolean generatePurls, File spdxFile, URI namespaceUri, OutputFormat outputFormatEnum) throws SpdxBuilderException, LicenseMapperException - Parameters:
mavenProject
- Maven projectgeneratePurls
- If true, generated Package URLs for all package referencesspdxFile
- File to store the SPDX document resultsnamespaceUri
- Namespace prefix for generated SPDX URIs document - must be uniqueoutputFormatEnum
- format for the SPDX document- Throws:
SpdxBuilderException
LicenseMapperException
-
-
Method Details
-
getSpdxDoc
public org.spdx.library.model.v3_0_1.core.SpdxDocument getSpdxDoc()- Returns:
- the SPDX Document
-
fillSpdxDocumentInformation
public void fillSpdxDocumentInformation(SpdxProjectInformation projectInformation) throws SpdxBuilderException - Specified by:
fillSpdxDocumentInformation
in classAbstractDocumentBuilder
- Parameters:
projectInformation
- Information about project extracted from Maven metadata and parameters- Throws:
SpdxBuilderException
- on errors adding document level information
-
collectSpdxFileInformation
public void collectSpdxFileInformation(List<org.apache.maven.shared.model.fileset.FileSet> sources, String baseDir, SpdxDefaultFileInformation defaultFileInformation, HashMap<String, SpdxDefaultFileInformation> pathSpecificInformation, Set<String> checksumAlgorithms) throws SpdxBuilderExceptionDescription copied from class:AbstractDocumentBuilder
Collect information at the file level, fill in the SPDX document- Specified by:
collectSpdxFileInformation
in classAbstractDocumentBuilder
- Parameters:
sources
- Source directories to be included in the documentbaseDir
- project base directory used to construct the relative paths for the SPDX filespathSpecificInformation
- Map of path to file information used to override the default file informationchecksumAlgorithms
- algorithms to use to generate checksums- Throws:
SpdxBuilderException
- on errors collecting files
-
saveSpdxDocumentToFile
Description copied from class:AbstractDocumentBuilder
Saves the SPDX document to the file- Specified by:
saveSpdxDocumentToFile
in classAbstractDocumentBuilder
- Throws:
SpdxBuilderException
- On any error saving the file
-
addNonStandardLicenses
public void addNonStandardLicenses(NonStandardLicense[] nonStandardLicenses) throws SpdxBuilderException - Specified by:
addNonStandardLicenses
in classAbstractDocumentBuilder
- Parameters:
nonStandardLicenses
- non standard licenses to add- Throws:
SpdxBuilderException
-
getProjectPackage
public org.spdx.core.CoreModelObject getProjectPackage()- Specified by:
getProjectPackage
in classAbstractDocumentBuilder
- Returns:
- package representing the Mave project
-
mavenLicenseListToSpdxLicenseExpression
public String mavenLicenseListToSpdxLicenseExpression(List<org.apache.maven.model.License> mavenLicenses) throws LicenseManagerException - Specified by:
mavenLicenseListToSpdxLicenseExpression
in classAbstractDocumentBuilder
- Parameters:
mavenLicenses
- list of licenses- Returns:
- license expression representing the list of mavenLicenses
- Throws:
LicenseManagerException
- On error converting license
-
getLicenseManager
- Returns:
- the licenseManager
-
verify
Description copied from class:AbstractDocumentBuilder
Verifies the top level document- Specified by:
verify
in classAbstractDocumentBuilder
- Returns:
- list of any errors or warnings
-