Class ComponentBomTask

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class ComponentBomTask
    extends org.apache.tools.ant.Task
    Task that creates CycloneDX BOMs for a single component.
    • Field Summary

      • Fields inherited from class org.apache.tools.ant.Task

        target, taskName, taskType, wrapper
      • Fields inherited from class org.apache.tools.ant.ProjectComponent

        description, location, project
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAdditionalComponent​(Component c)
      Adds another component to the SBOM.
      void addConfiguredLicense​(License l)
      Adds a license to the SBOM's metadata.
      void addToolComponent​(Component c)
      Adds component to be added to the metadata.tools section of the SBOM.
      Component createComponent()
      Sets the component for the SBOM.
      Organization createManufacturer()
      Sets the manufacturer of the SBOM.
      org.apache.tools.ant.types.resources.Union createPureFileComponents()
      Accepts arbitrary file-system only resources that will be added as components of type file.
      Organization createSupplier()
      Sets the supplier of the SBOM.
      void execute()  
      void setBomName​(java.lang.String bomName)
      Sets the base name of the generated BOM.
      void setFormat​(OutputFormat format)
      Which serialization format of CycloneDX SBOM to use.
      void setOutputDirectory​(java.io.File f)
      Sets the output directory for the generated SBOM.
      void setSerialNumber​(java.lang.String serialNumber)
      Specifies the serial number of the BOM.
      void setSpecVersion​(SpecVersion specVersion)
      Specifies the CycloneDX version to use.
      void setUseComponentManufacturer​(boolean useComponentManufacturer)
      Whether to use the manufacturer of the main component as manufacturer for the BOM as well.
      void setUseComponentSupplier​(boolean useComponentSupplier)
      Whether to use the supplier of the main component as supplier for the BOM as well.
      • Methods inherited from class org.apache.tools.ant.Task

        bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
      • Methods inherited from class org.apache.tools.ant.ProjectComponent

        clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ComponentBomTask

        public ComponentBomTask()
    • Method Detail

      • setSpecVersion

        public void setSpecVersion​(SpecVersion specVersion)
        Specifies the CycloneDX version to use.

        Defaults to 1.7.

        Parameters:
        specVersion - specification version
      • setSerialNumber

        public void setSerialNumber​(java.lang.String serialNumber)
        Specifies the serial number of the BOM.

        The default behavior is to generate a new random serial number for each BOM generated like the spec recommends. This default behavior can be specified explicitly be setting the value to "random".

        Parameters:
        serialNumber - serial number for the SBOM. Must be a valid RFC 4122 UUID URN or the literal String "random".
        Since:
        CycloneDX Antlib 0.2
      • setFormat

        public void setFormat​(OutputFormat format)
        Which serialization format of CycloneDX SBOM to use.
        Parameters:
        format - output format
      • setBomName

        public void setBomName​(java.lang.String bomName)
        Sets the base name of the generated BOM.

        The file name will be the base name plus the extension of the {@see #setFormat format}.

        Parameters:
        bomName - base name of generated file
      • setOutputDirectory

        public void setOutputDirectory​(java.io.File f)
        Sets the output directory for the generated SBOM.
        Parameters:
        f - output directory
      • setUseComponentSupplier

        public void setUseComponentSupplier​(boolean useComponentSupplier)
        Whether to use the supplier of the main component as supplier for the BOM as well.
        Parameters:
        useComponentSupplier - whether to use supplier of component for the BOM
      • setUseComponentManufacturer

        public void setUseComponentManufacturer​(boolean useComponentManufacturer)
        Whether to use the manufacturer of the main component as manufacturer for the BOM as well.
        Parameters:
        useComponentManufacturer - whether to use manufacturer of component for the BOM
      • createComponent

        public Component createComponent()
        Sets the component for the SBOM.
        Returns:
        container for main component
      • createManufacturer

        public Organization createManufacturer()
        Sets the manufacturer of the SBOM.

        At most one manufacturer can be set.

        Returns:
        manufaturer of SBOM
      • createSupplier

        public Organization createSupplier()
        Sets the supplier of the SBOM.

        At most one supplier can be set.

        Returns:
        supplier of SBOM
      • addConfiguredLicense

        public void addConfiguredLicense​(License l)
        Adds a license to the SBOM's metadata.
        Parameters:
        l - SBOM's license
      • addAdditionalComponent

        public void addAdditionalComponent​(Component c)
        Adds another component to the SBOM.
        Parameters:
        c - component to be added to SBOM
      • addToolComponent

        public void addToolComponent​(Component c)
        Adds component to be added to the metadata.tools section of the SBOM.

        This is meant to be used by tools that have also taken part in the generation of this SBOM.

        Parameters:
        c - component to be added to tools
      • createPureFileComponents

        public org.apache.tools.ant.types.resources.Union createPureFileComponents()
        Accepts arbitrary file-system only resources that will be added as components of type file.
        Returns:
        container for pure file components
      • execute

        public void execute()
        Overrides:
        execute in class org.apache.tools.ant.Task