Package org.spdx.maven.utils
Class SpdxV2DocumentBuilder
java.lang.Object
org.spdx.maven.utils.AbstractDocumentBuilder
org.spdx.maven.utils.SpdxV2DocumentBuilder
Builder for SPDX Spec version 2 SPDX Documents
- Author:
- Gary O'Neall
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SpdxV2LicenseManager
protected org.spdx.library.model.v2.SpdxPackage
protected org.spdx.library.model.v2.SpdxDocument
Fields inherited from class org.spdx.maven.utils.AbstractDocumentBuilder
copyManager, format, generatePurls, modelStore, NULL_SHA1, outputFormatEnum, project, spdxFile, UNSPECIFIED
-
Constructor Summary
ConstructorsConstructorDescriptionSpdxV2DocumentBuilder
(org.apache.maven.project.MavenProject mavenProject, boolean generatePurls, File spdxFile, URI spdxDocumentNamespace, 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 documentorg.spdx.library.model.v2.ExternalRef
convertExternalRef
(ExternalReference externalReference) void
fillSpdxDocumentInformation
(SpdxProjectInformation projectInformation) org.spdx.core.CoreModelObject
org.spdx.library.model.v2.SpdxDocument
mavenLicenseListToSpdxLicenseExpression
(List<org.apache.maven.model.License> mavenLicenses) void
Saves the SPDX document to the fileverify()
Verifies the top level document
-
Field Details
-
spdxDoc
protected org.spdx.library.model.v2.SpdxDocument spdxDoc -
licenseManager
-
projectPackage
protected org.spdx.library.model.v2.SpdxPackage projectPackage
-
-
Constructor Details
-
SpdxV2DocumentBuilder
public SpdxV2DocumentBuilder(org.apache.maven.project.MavenProject mavenProject, boolean generatePurls, File spdxFile, URI spdxDocumentNamespace, OutputFormat outputFormatEnum) throws SpdxBuilderException, LicenseMapperException - Parameters:
mavenProject
- Maven projectgeneratePurls
- If true, generated Package URLs for all package referencesspdxFile
- File to store the SPDX document resultsspdxDocumentNamespace
- SPDX Document namespace - must be uniqueoutputFormatEnum
- output format to use for storing the SPDX file- Throws:
SpdxBuilderException
LicenseMapperException
-
-
Method Details
-
getSpdxDoc
public org.spdx.library.model.v2.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
-
convertExternalRef
public org.spdx.library.model.v2.ExternalRef convertExternalRef(ExternalReference externalReference) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
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
-
verify
Description copied from class:AbstractDocumentBuilder
Verifies the top level document- Specified by:
verify
in classAbstractDocumentBuilder
- Returns:
- list of any errors or warnings
-
getLicenseManager
- Returns:
- the license manager
-