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.CreationInfoprotected 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 SpdxV3LicenseManagerprotected org.spdx.library.model.v3_0_1.software.SpdxPackageprotected org.spdx.library.model.v3_0_1.software.Sbomprotected org.spdx.library.model.v3_0_1.core.SpdxDocumentFields 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 TypeMethodDescriptionvoidaddNonStandardLicenses(NonStandardLicense[] nonStandardLicenses) voidcollectSpdxFileInformation(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 documentvoidfillSpdxDocumentInformation(SpdxProjectInformation projectInformation) org.spdx.core.CoreModelObjectorg.spdx.library.model.v3_0_1.core.SpdxDocumentmavenLicenseListToSpdxLicenseExpression(List<org.apache.maven.model.License> mavenLicenses) voidSaves 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:
SpdxBuilderExceptionLicenseMapperException
-
-
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:
fillSpdxDocumentInformationin 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:AbstractDocumentBuilderCollect information at the file level, fill in the SPDX document- Specified by:
collectSpdxFileInformationin classAbstractDocumentBuilder- Parameters:
sources- Source directories to be included in the documentbaseDir- project base directory used to construct the relative paths for the SPDX filesdefaultFileInformation- Information on default SPDX field data for the 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:AbstractDocumentBuilderSaves the SPDX document to the file- Specified by:
saveSpdxDocumentToFilein classAbstractDocumentBuilder- Throws:
SpdxBuilderException- On any error saving the file
-
addNonStandardLicenses
public void addNonStandardLicenses(NonStandardLicense[] nonStandardLicenses) throws SpdxBuilderException - Specified by:
addNonStandardLicensesin classAbstractDocumentBuilder- Parameters:
nonStandardLicenses- non standard licenses to add- Throws:
SpdxBuilderException
-
getProjectPackage
public org.spdx.core.CoreModelObject getProjectPackage()- Specified by:
getProjectPackagein classAbstractDocumentBuilder- Returns:
- package representing the Maven project
-
mavenLicenseListToSpdxLicenseExpression
public String mavenLicenseListToSpdxLicenseExpression(List<org.apache.maven.model.License> mavenLicenses) throws LicenseManagerException - Specified by:
mavenLicenseListToSpdxLicenseExpressionin 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:AbstractDocumentBuilderVerifies the top level document- Specified by:
verifyin classAbstractDocumentBuilder- Returns:
- list of any errors or warnings
-