From 2d40108b59eca50a90f9d09bb42ee317e58ef451 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 18 Nov 2023 12:47:43 +1000 Subject: [PATCH] make classifier used to attach the sbom configurable Signed-off-by: Olivier Lamy --- README.md | 2 +- .../java/org/cyclonedx/maven/BaseCycloneDxMojo.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b08189d..6a0f0028 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The CycloneDX Maven plugin contains the following three goals: * `makeAggregateBom`: creates an aggregate BOM at build root (with dependencies from the whole multi-modules build), and eventually a BOM for each module, * `makePackageBom`: creates a BOM for each Maven module with `war` or `ear` packaging. -By default, the BOM(s) will be attached as an additional artifacts with `cyclonedx` classifier and `xml` or `json` extension during a Maven `install` or `deploy`: +By default, the BOM(s) will be attached as an additional artifacts with `cyclonedx` classifier (can be customized by setting `cyclonedx.classifier`) and `xml` or `json` extension during a Maven `install` or `deploy`: * `${project.artifactId}-${project.version}-cyclonedx.xml` * `${project.artifactId}-${project.version}-cyclonedx.json` diff --git a/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java b/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java index 78e6dd83..386383e9 100644 --- a/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java +++ b/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java @@ -199,6 +199,14 @@ public abstract class BaseCycloneDxMojo extends AbstractMojo { @Parameter(property = "cyclonedx.skipAttach", defaultValue = "false", required = false) private boolean skipAttach = false; + /** + * Classifier of the attached sbom + * + * @since 2.8.1 + */ + @Parameter(property = "cyclonedx.classifier", defaultValue = "cyclonedx") + private String classifier; + /** * Verbose output. * @@ -456,7 +464,7 @@ private void saveBomToFile(String bomString, String extension, Parser bomParser) if (!skipAttach) { getLog().info(String.format(MESSAGE_ATTACHING_BOM, project.getArtifactId(), project.getVersion(), extension)); - mavenProjectHelper.attachArtifact(project, extension, "cyclonedx", bomFile); + mavenProjectHelper.attachArtifact(project, extension, classifier, bomFile); } }