From 8099fa5a5c6ac27393fdefc1caaf2fcdeb3ef48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Tue, 23 Jan 2024 05:06:58 +0100 Subject: [PATCH] add 'build' lifecycle when CDX 1.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hervé Boutemy --- .../java/org/cyclonedx/maven/BaseCycloneDxMojo.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java b/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java index aa2d4ab9..8a4aac41 100644 --- a/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java +++ b/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java @@ -39,6 +39,8 @@ import org.cyclonedx.model.Component; import org.cyclonedx.model.Dependency; import org.cyclonedx.model.ExternalReference; +import org.cyclonedx.model.LifecycleChoice; +import org.cyclonedx.model.Lifecycles; import org.cyclonedx.model.Metadata; import org.cyclonedx.model.Property; import org.cyclonedx.parsers.JsonParser; @@ -50,6 +52,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -384,6 +387,14 @@ private void generateBom(String analysis, Metadata metadata, List com } }*/ + if (schemaVersion().getVersion() >= 1.5) { + LifecycleChoice build = new LifecycleChoice(); + build.setPhase(LifecycleChoice.Phase.BUILD); + Lifecycles lifecycles = new Lifecycles(); + lifecycles.setLifecycleChoice(Collections.singletonList(build)); + metadata.setLifecycles(lifecycles); + } + if ("all".equalsIgnoreCase(outputFormat) || "xml".equalsIgnoreCase(outputFormat) || "json".equalsIgnoreCase(outputFormat)) {