Class BaseCycloneDxMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    CycloneDxMojo, CycloneDxPackageMojo

    public abstract class BaseCycloneDxMojo
    extends org.apache.maven.plugin.AbstractMojo
    • Constructor Detail

      • BaseCycloneDxMojo

        public BaseCycloneDxMojo()
    • Method Detail

      • getProject

        protected org.apache.maven.project.MavenProject getProject()
        Returns a reference to the current project.
        Returns:
        returns a reference to the current project
      • generatePackageUrl

        protected String generatePackageUrl​(org.apache.maven.artifact.Artifact artifact)
      • convert

        protected org.cyclonedx.model.Component convert​(org.apache.maven.artifact.Artifact artifact)
      • extractComponentsAndDependencies

        protected abstract String extractComponentsAndDependencies​(Set<String> topLevelComponents,
                                                                   Map<String,​org.cyclonedx.model.Component> components,
                                                                   Map<String,​org.cyclonedx.model.Dependency> dependencies)
                                                            throws org.apache.maven.plugin.MojoExecutionException
        Analyze the current Maven project to extract the BOM components list and their dependencies.
        Parameters:
        topLevelComponents - the PURLs for all top level components
        components - the components map to fill
        dependencies - the dependencies map to fill
        Returns:
        the name of the analysis done to store as a BOM, or null to not save result.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - something weird happened...
      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • extractBOMDependencies

        protected Map<String,​org.cyclonedx.model.Dependency> extractBOMDependencies​(org.apache.maven.project.MavenProject mavenProject)
                                                                                   throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • schemaVersion

        protected org.cyclonedx.CycloneDxSchema.Version schemaVersion()
        Resolves the CycloneDX schema the mojo has been requested to use.
        Returns:
        the CycloneDX schema to use
      • logAdditionalParameters

        protected void logAdditionalParameters()
      • logParameters

        protected void logParameters()
      • populateComponents

        protected void populateComponents​(Set<String> topLevelComponents,
                                          Map<String,​org.cyclonedx.model.Component> components,
                                          Set<org.apache.maven.artifact.Artifact> artifacts,
                                          org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis dependencyAnalysis)
      • inferComponentScope

        protected org.cyclonedx.model.Component.Scope inferComponentScope​(org.apache.maven.artifact.Artifact artifact,
                                                                          org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis projectDependencyAnalysis)
        Infer BOM component scope (required/optional/excluded) based on Maven project dependency analysis.
        Parameters:
        artifact - Artifact from maven project
        projectDependencyAnalysis - Maven Project Dependency Analysis data
        Returns:
        Component.Scope - REQUIRED: If the component is used (as detected by project dependency analysis). OPTIONAL: If it is unused