Class AbstractDocumentBuilder

java.lang.Object
org.spdx.maven.utils.AbstractDocumentBuilder
Direct Known Subclasses:
SpdxV2DocumentBuilder, SpdxV3DocumentBuilder

public abstract class AbstractDocumentBuilder extends Object
Abstract class to create SPDX documents.

Subclasses of this class implement specific SPDX specification versions of the document

Author:
Gary O'Neall
  • Field Details

    • UNSPECIFIED

      protected static final String UNSPECIFIED
      See Also:
    • NULL_SHA1

      public static final String NULL_SHA1
      See Also:
    • project

      protected org.apache.maven.project.MavenProject project
    • generatePurls

      protected boolean generatePurls
    • spdxFile

      protected File spdxFile
    • outputFormatEnum

      protected OutputFormat outputFormatEnum
    • modelStore

      protected org.spdx.storage.ISerializableModelStore modelStore
    • copyManager

      protected ModelCopyManager copyManager
    • format

      protected DateFormat format
  • Constructor Details

    • AbstractDocumentBuilder

      public AbstractDocumentBuilder(org.apache.maven.project.MavenProject project, boolean generatePurls, File spdxFile, OutputFormat outputFormatEnum) throws SpdxBuilderException
      Parameters:
      project - Maven Project
      generatePurls - If true, generated Package URLs for all package references
      spdxFile - File to store the SPDX document results
      outputFormatEnum - File format for the SPDX file
      Throws:
      SpdxBuilderException - On errors building the document
  • Method Details

    • fillSpdxDocumentInformation

      public abstract void fillSpdxDocumentInformation(SpdxProjectInformation projectInformation) throws SpdxBuilderException
      Parameters:
      projectInformation - Information about project extracted from Maven metadata and parameters
      Throws:
      SpdxBuilderException - on errors adding document level information
    • collectSpdxFileInformation

      public abstract void collectSpdxFileInformation(List<org.apache.maven.shared.model.fileset.FileSet> sources, String baseDir, SpdxDefaultFileInformation defaultFileInformation, HashMap<String,SpdxDefaultFileInformation> pathSpecificInformation, Set<String> checksumAlgorithms) throws SpdxBuilderException
      Collect information at the file level, fill in the SPDX document
      Parameters:
      sources - Source directories to be included in the document
      baseDir - project base directory used to construct the relative paths for the SPDX files
      pathSpecificInformation - Map of path to file information used to override the default file information
      checksumAlgorithms - algorithms to use to generate checksums
      Throws:
      SpdxBuilderException - on errors collecting files
    • saveSpdxDocumentToFile

      public abstract void saveSpdxDocumentToFile() throws SpdxBuilderException
      Saves the SPDX document to the file
      Throws:
      SpdxBuilderException - On any error saving the file
    • addNonStandardLicenses

      public abstract void addNonStandardLicenses(NonStandardLicense[] nonStandardLicenses) throws SpdxBuilderException
      Parameters:
      nonStandardLicenses - non standard licenses to add
      Throws:
      SpdxBuilderException
    • getProjectPackage

      public abstract org.spdx.core.CoreModelObject getProjectPackage()
      Returns:
      package representing the Mave project
    • mavenLicenseListToSpdxLicenseExpression

      public abstract String mavenLicenseListToSpdxLicenseExpression(List<org.apache.maven.model.License> mavenLicenses) throws LicenseManagerException
      Parameters:
      mavenLicenses - list of licenses
      Returns:
      license expression representing the list of mavenLicenses
      Throws:
      LicenseManagerException - On error converting license
    • verify

      public abstract List<String> verify()
      Verifies the top level document
      Returns:
      list of any errors or warnings