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 SpdxV2LicenseManagerprotected org.spdx.library.model.v2.SpdxPackageprotected org.spdx.library.model.v2.SpdxDocumentFields 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 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 documentorg.spdx.library.model.v2.ExternalRefconvertExternalRef(ExternalReference externalReference) voidfillSpdxDocumentInformation(SpdxProjectInformation projectInformation) org.spdx.core.CoreModelObjectorg.spdx.library.model.v2.SpdxDocumentmavenLicenseListToSpdxLicenseExpression(List<org.apache.maven.model.License> mavenLicenses) voidSaves 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:
SpdxBuilderExceptionLicenseMapperException
-
-
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:
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
-
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:
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
-
verify
Description copied from class:AbstractDocumentBuilderVerifies the top level document- Specified by:
verifyin classAbstractDocumentBuilder- Returns:
- list of any errors or warnings
-
getLicenseManager
- Returns:
- the license manager
-