Skip to content

Commit

Permalink
add 'build' lifecycle when CDX 1.5
Browse files Browse the repository at this point in the history
Signed-off-by: Hervé Boutemy <hboutemy@apache.org>
  • Loading branch information
hboutemy committed Mar 10, 2024
1 parent 3fa2532 commit 8099fa5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -384,6 +387,14 @@ private void generateBom(String analysis, Metadata metadata, List<Component> 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)) {
Expand Down

0 comments on commit 8099fa5

Please sign in to comment.