This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ant-antlibs-cyclonedx.git


The following commit(s) were added to refs/heads/main by this push:
     new 4309a0b  add an "all" format to create json and xml from a single bom
4309a0b is described below

commit 4309a0b061077e65fcb6b56a22f6c60003e3beab
Author: Stefan Bodewig <[email protected]>
AuthorDate: Sat May 2 07:55:09 2026 +0200

    add an "all" format to create json and xml from a single bom
---
 ....json => ant-cyclonedx-0.1alpha-cyclonedx.json} | 36 ++++----
 ...om.xml => ant-cyclonedx-0.1alpha-cyclonedx.xml} | 36 ++++----
 .../org/apache/ant/cyclonedx/ComponentBomTask.java | 28 +++++--
 .../org/apache/ant/cyclonedx/OutputFormat.java     | 21 +++++
 src/tests/antunit/componentbom-test.xml            | 96 +++++-----------------
 src/tests/antunit/shared.xml                       |  1 +
 6 files changed, 99 insertions(+), 119 deletions(-)

diff --git a/examples/bom.json b/examples/ant-cyclonedx-0.1alpha-cyclonedx.json
similarity index 70%
rename from examples/bom.json
rename to examples/ant-cyclonedx-0.1alpha-cyclonedx.json
index 07879a3..ef9c253 100644
--- a/examples/bom.json
+++ b/examples/ant-cyclonedx-0.1alpha-cyclonedx.json
@@ -1,10 +1,10 @@
 {
   "bomFormat" : "CycloneDX",
   "specVersion" : "1.6",
-  "serialNumber" : "urn:uuid:932573e3-25d5-4922-a5a1-eaa64e76a184",
+  "serialNumber" : "urn:uuid:9bc01eb7-5c9c-4579-8a08-dae8dbbf6820",
   "version" : 1,
   "metadata" : {
-    "timestamp" : "2026-05-01T20:44:53Z",
+    "timestamp" : "2026-05-02T05:54:06Z",
     "lifecycles" : [
       {
         "phase" : "build"
@@ -33,35 +33,35 @@
           "hashes" : [
             {
               "alg" : "MD5",
-              "content" : "6802fde2fdd7103022fb9203fc8ceed2"
+              "content" : "df005ba963df3f6f51e9323c150619e1"
             },
             {
               "alg" : "SHA-1",
-              "content" : "06ff4239c338b0e9a6f6b8567a79126c957d4187"
+              "content" : "1cb95c53d0af659db41067416c5bd6779faa9e73"
             },
             {
               "alg" : "SHA-256",
-              "content" : 
"480ace3a039d882edb028227aa8ae682cb18fe40461ad757bd04dce7ed513b3f"
+              "content" : 
"a5842cd356a394ecab0931639633721ffb5f1001178310a1e62963ea19be8534"
             },
             {
               "alg" : "SHA-512",
-              "content" : 
"e888ecde1d5bbf5b1aef63364bbcabf8f0c92e63379b0bedc085a68c117c011730f643bb9a105157c4eb529190abd3df5b16f61826df85082819b96b2b813b6a"
+              "content" : 
"ec06e7292f1ec1cd367d7000854d96e42a1f2e46d15ba0d09895ef1fb33e604d4a1cb6a2131a3948b24913c2c97b63f04247e580e0147d9f8fbe3fd05aa38ccd"
             },
             {
               "alg" : "SHA3-256",
-              "content" : 
"39716ad8b6b6081eefc5a3f61095b39ec650147dbe9bd5a238ada8e732b8bd41"
+              "content" : 
"89717eccb2f874580c437d0b4be1ba1854d5aa6f55748a9e97184cbc82b91c7c"
             },
             {
               "alg" : "SHA3-512",
-              "content" : 
"23e9d1ddc7745d71e55f912246d1cd6f23f14e9000fdeb6911b17d8c305718cb2df9f7d8219c21f89d74709a3ed8b440111b62297b67e6f6a5deb2912769a201"
+              "content" : 
"324a5f2a6cda6c0432e9088428a78b60cdc083241ff88a4c7c4396c498ad06abe2c20a25047bf1d0b607f2aa293aaf88deecc003bd94853af2fcd6fa3567c83b"
             },
             {
               "alg" : "SHA-384",
-              "content" : 
"461a095ee273e71bfb09659ccf3aa548890058057b59a8d069b5f7bea9a3a437be316c1e61e3e7ca6852202d5ae1d6a6"
+              "content" : 
"7d323876ba131dff76d8401ef95edb6376ba6034ec2017c8bbd270519527c8090931c862bfaca8024cbf04a0e218c1b5"
             },
             {
               "alg" : "SHA3-384",
-              "content" : 
"1b3cb728b5eaab8e62538ab986e8ccb4c1370799fbe7f1c8c60702f270a91c566e172ceed7f5fb0acb9cf53e7300f38a"
+              "content" : 
"8bf326b3d613c5fb7740739c9d1625eb54b9f2487a9dcf498e8fdfb44bf186dd3b467ec179d8efb17f84a7fd765bc800"
             }
           ],
           "licenses" : [
@@ -103,35 +103,35 @@
       "hashes" : [
         {
           "alg" : "MD5",
-          "content" : "6802fde2fdd7103022fb9203fc8ceed2"
+          "content" : "df005ba963df3f6f51e9323c150619e1"
         },
         {
           "alg" : "SHA-1",
-          "content" : "06ff4239c338b0e9a6f6b8567a79126c957d4187"
+          "content" : "1cb95c53d0af659db41067416c5bd6779faa9e73"
         },
         {
           "alg" : "SHA-256",
-          "content" : 
"480ace3a039d882edb028227aa8ae682cb18fe40461ad757bd04dce7ed513b3f"
+          "content" : 
"a5842cd356a394ecab0931639633721ffb5f1001178310a1e62963ea19be8534"
         },
         {
           "alg" : "SHA-512",
-          "content" : 
"e888ecde1d5bbf5b1aef63364bbcabf8f0c92e63379b0bedc085a68c117c011730f643bb9a105157c4eb529190abd3df5b16f61826df85082819b96b2b813b6a"
+          "content" : 
"ec06e7292f1ec1cd367d7000854d96e42a1f2e46d15ba0d09895ef1fb33e604d4a1cb6a2131a3948b24913c2c97b63f04247e580e0147d9f8fbe3fd05aa38ccd"
         },
         {
           "alg" : "SHA3-256",
-          "content" : 
"39716ad8b6b6081eefc5a3f61095b39ec650147dbe9bd5a238ada8e732b8bd41"
+          "content" : 
"89717eccb2f874580c437d0b4be1ba1854d5aa6f55748a9e97184cbc82b91c7c"
         },
         {
           "alg" : "SHA3-512",
-          "content" : 
"23e9d1ddc7745d71e55f912246d1cd6f23f14e9000fdeb6911b17d8c305718cb2df9f7d8219c21f89d74709a3ed8b440111b62297b67e6f6a5deb2912769a201"
+          "content" : 
"324a5f2a6cda6c0432e9088428a78b60cdc083241ff88a4c7c4396c498ad06abe2c20a25047bf1d0b607f2aa293aaf88deecc003bd94853af2fcd6fa3567c83b"
         },
         {
           "alg" : "SHA-384",
-          "content" : 
"461a095ee273e71bfb09659ccf3aa548890058057b59a8d069b5f7bea9a3a437be316c1e61e3e7ca6852202d5ae1d6a6"
+          "content" : 
"7d323876ba131dff76d8401ef95edb6376ba6034ec2017c8bbd270519527c8090931c862bfaca8024cbf04a0e218c1b5"
         },
         {
           "alg" : "SHA3-384",
-          "content" : 
"1b3cb728b5eaab8e62538ab986e8ccb4c1370799fbe7f1c8c60702f270a91c566e172ceed7f5fb0acb9cf53e7300f38a"
+          "content" : 
"8bf326b3d613c5fb7740739c9d1625eb54b9f2487a9dcf498e8fdfb44bf186dd3b467ec179d8efb17f84a7fd765bc800"
         }
       ],
       "licenses" : [
diff --git a/examples/bom.xml b/examples/ant-cyclonedx-0.1alpha-cyclonedx.xml
similarity index 65%
rename from examples/bom.xml
rename to examples/ant-cyclonedx-0.1alpha-cyclonedx.xml
index b557624..dca9bb7 100644
--- a/examples/bom.xml
+++ b/examples/ant-cyclonedx-0.1alpha-cyclonedx.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bom serialNumber="urn:uuid:1544955e-349c-4a57-9a24-3e7ec9bda318" version="1" 
xmlns="http://cyclonedx.org/schema/bom/1.6";>
+<bom serialNumber="urn:uuid:9bc01eb7-5c9c-4579-8a08-dae8dbbf6820" version="1" 
xmlns="http://cyclonedx.org/schema/bom/1.6";>
   <metadata>
-    <timestamp>2026-05-01T20:44:53Z</timestamp>
+    <timestamp>2026-05-02T05:54:06Z</timestamp>
     <lifecycles>
       <lifecycle>
         <phase>build</phase>
@@ -23,14 +23,14 @@
           <version>0.1alpha</version>
           <description>Apache CycloneDX Antlib</description>
           <hashes>
-            <hash alg="MD5">6802fde2fdd7103022fb9203fc8ceed2</hash>
-            <hash alg="SHA-1">06ff4239c338b0e9a6f6b8567a79126c957d4187</hash>
-            <hash 
alg="SHA-256">480ace3a039d882edb028227aa8ae682cb18fe40461ad757bd04dce7ed513b3f</hash>
-            <hash 
alg="SHA-512">e888ecde1d5bbf5b1aef63364bbcabf8f0c92e63379b0bedc085a68c117c011730f643bb9a105157c4eb529190abd3df5b16f61826df85082819b96b2b813b6a</hash>
-            <hash 
alg="SHA3-256">39716ad8b6b6081eefc5a3f61095b39ec650147dbe9bd5a238ada8e732b8bd41</hash>
-            <hash 
alg="SHA3-512">23e9d1ddc7745d71e55f912246d1cd6f23f14e9000fdeb6911b17d8c305718cb2df9f7d8219c21f89d74709a3ed8b440111b62297b67e6f6a5deb2912769a201</hash>
-            <hash 
alg="SHA-384">461a095ee273e71bfb09659ccf3aa548890058057b59a8d069b5f7bea9a3a437be316c1e61e3e7ca6852202d5ae1d6a6</hash>
-            <hash 
alg="SHA3-384">1b3cb728b5eaab8e62538ab986e8ccb4c1370799fbe7f1c8c60702f270a91c566e172ceed7f5fb0acb9cf53e7300f38a</hash>
+            <hash alg="MD5">df005ba963df3f6f51e9323c150619e1</hash>
+            <hash alg="SHA-1">1cb95c53d0af659db41067416c5bd6779faa9e73</hash>
+            <hash 
alg="SHA-256">a5842cd356a394ecab0931639633721ffb5f1001178310a1e62963ea19be8534</hash>
+            <hash 
alg="SHA-512">ec06e7292f1ec1cd367d7000854d96e42a1f2e46d15ba0d09895ef1fb33e604d4a1cb6a2131a3948b24913c2c97b63f04247e580e0147d9f8fbe3fd05aa38ccd</hash>
+            <hash 
alg="SHA3-256">89717eccb2f874580c437d0b4be1ba1854d5aa6f55748a9e97184cbc82b91c7c</hash>
+            <hash 
alg="SHA3-512">324a5f2a6cda6c0432e9088428a78b60cdc083241ff88a4c7c4396c498ad06abe2c20a25047bf1d0b607f2aa293aaf88deecc003bd94853af2fcd6fa3567c83b</hash>
+            <hash 
alg="SHA-384">7d323876ba131dff76d8401ef95edb6376ba6034ec2017c8bbd270519527c8090931c862bfaca8024cbf04a0e218c1b5</hash>
+            <hash 
alg="SHA3-384">8bf326b3d613c5fb7740739c9d1625eb54b9f2487a9dcf498e8fdfb44bf186dd3b467ec179d8efb17f84a7fd765bc800</hash>
           </hashes>
           <licenses>
             <license>
@@ -60,14 +60,14 @@
       <version>0.1alpha</version>
       <description>Apache CycloneDX Antlib</description>
       <hashes>
-        <hash alg="MD5">6802fde2fdd7103022fb9203fc8ceed2</hash>
-        <hash alg="SHA-1">06ff4239c338b0e9a6f6b8567a79126c957d4187</hash>
-        <hash 
alg="SHA-256">480ace3a039d882edb028227aa8ae682cb18fe40461ad757bd04dce7ed513b3f</hash>
-        <hash 
alg="SHA-512">e888ecde1d5bbf5b1aef63364bbcabf8f0c92e63379b0bedc085a68c117c011730f643bb9a105157c4eb529190abd3df5b16f61826df85082819b96b2b813b6a</hash>
-        <hash 
alg="SHA3-256">39716ad8b6b6081eefc5a3f61095b39ec650147dbe9bd5a238ada8e732b8bd41</hash>
-        <hash 
alg="SHA3-512">23e9d1ddc7745d71e55f912246d1cd6f23f14e9000fdeb6911b17d8c305718cb2df9f7d8219c21f89d74709a3ed8b440111b62297b67e6f6a5deb2912769a201</hash>
-        <hash 
alg="SHA-384">461a095ee273e71bfb09659ccf3aa548890058057b59a8d069b5f7bea9a3a437be316c1e61e3e7ca6852202d5ae1d6a6</hash>
-        <hash 
alg="SHA3-384">1b3cb728b5eaab8e62538ab986e8ccb4c1370799fbe7f1c8c60702f270a91c566e172ceed7f5fb0acb9cf53e7300f38a</hash>
+        <hash alg="MD5">df005ba963df3f6f51e9323c150619e1</hash>
+        <hash alg="SHA-1">1cb95c53d0af659db41067416c5bd6779faa9e73</hash>
+        <hash 
alg="SHA-256">a5842cd356a394ecab0931639633721ffb5f1001178310a1e62963ea19be8534</hash>
+        <hash 
alg="SHA-512">ec06e7292f1ec1cd367d7000854d96e42a1f2e46d15ba0d09895ef1fb33e604d4a1cb6a2131a3948b24913c2c97b63f04247e580e0147d9f8fbe3fd05aa38ccd</hash>
+        <hash 
alg="SHA3-256">89717eccb2f874580c437d0b4be1ba1854d5aa6f55748a9e97184cbc82b91c7c</hash>
+        <hash 
alg="SHA3-512">324a5f2a6cda6c0432e9088428a78b60cdc083241ff88a4c7c4396c498ad06abe2c20a25047bf1d0b607f2aa293aaf88deecc003bd94853af2fcd6fa3567c83b</hash>
+        <hash 
alg="SHA-384">7d323876ba131dff76d8401ef95edb6376ba6034ec2017c8bbd270519527c8090931c862bfaca8024cbf04a0e218c1b5</hash>
+        <hash 
alg="SHA3-384">8bf326b3d613c5fb7740739c9d1625eb54b9f2487a9dcf498e8fdfb44bf186dd3b467ec179d8efb17f84a7fd765bc800</hash>
       </hashes>
       <licenses>
         <license>
diff --git a/src/main/org/apache/ant/cyclonedx/ComponentBomTask.java 
b/src/main/org/apache/ant/cyclonedx/ComponentBomTask.java
index d7d5cad..2919579 100644
--- a/src/main/org/apache/ant/cyclonedx/ComponentBomTask.java
+++ b/src/main/org/apache/ant/cyclonedx/ComponentBomTask.java
@@ -10,6 +10,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 import java.util.UUID;
 
@@ -34,19 +35,24 @@ import org.cyclonedx.model.OrganizationalEntity;
  */
 public class ComponentBomTask extends Task {
 
-    private File bomFile;
-    private Format format = Format.JSON;
+    private File outputDirectory;
+    private String bomName = "bom";
+    private OutputFormat format = OutputFormat.json;
     private Component component;
     private List<Component> additionalComponents = new ArrayList<>();
     private Organization manufacturer = null;
     private Organization supplier = null;
     private boolean useComponentSupplier = false;
 
-    public void setBomFile(File f) {
-        bomFile = f;
+    public void setOutputDirectory(File f) {
+        outputDirectory = f;
     }
 
-    public void setFormat(Format format) {
+    public void setBomName(String bomName) {
+        this.bomName = bomName;
+    }
+
+    public void setFormat(OutputFormat format) {
         this.format = format;
     }
 
@@ -86,10 +92,17 @@ public class ComponentBomTask extends Task {
         if (supplier != null && useComponentSupplier) {
             throw new BuildException("can't use component's supplier when 
there is an explicit supplier");
         }
+        if (outputDirectory == null || !outputDirectory.isDirectory()) {
+            throw new BuildException("outputDirectory must point to a 
directory");
+        }
 
         try {
             Bom bom = createBom();
-            writeBom(bom, bomFile);
+            for (Format f : format.getCycloneDxFormats()) {
+                writeBom(bom, f,
+                         new File(outputDirectory,
+                                  bomName + "." + 
f.name().toLowerCase(Locale.ENGLISH)));
+            }
         } catch (IOException | GeneratorException ex) {
             throw new BuildException("failed to write BOM", ex);
         }
@@ -182,7 +195,8 @@ public class ComponentBomTask extends Task {
         bom.setDependencies(dependencies);
     }
 
-    private void writeBom(Bom bom, File bomFile) throws IOException, 
GeneratorException {
+    private void writeBom(Bom bom, Format format, File bomFile)
+        throws IOException, GeneratorException {
         switch (format) {
         case JSON:
             writeJsonBom(bom, bomFile);
diff --git a/src/main/org/apache/ant/cyclonedx/OutputFormat.java 
b/src/main/org/apache/ant/cyclonedx/OutputFormat.java
new file mode 100644
index 0000000..21c02c3
--- /dev/null
+++ b/src/main/org/apache/ant/cyclonedx/OutputFormat.java
@@ -0,0 +1,21 @@
+package org.apache.ant.cyclonedx;
+
+import java.util.Arrays;
+
+import org.cyclonedx.Format;
+
+public enum OutputFormat {
+    json(Format.JSON),
+    xml(Format.XML),
+    all(Format.JSON, Format.XML);
+
+    private Format[] formats;
+
+    private OutputFormat(Format... formats) {
+        this.formats = formats;
+    }
+
+    public Iterable<Format> getCycloneDxFormats() {
+        return Arrays.asList(formats);
+    }
+}
diff --git a/src/tests/antunit/componentbom-test.xml 
b/src/tests/antunit/componentbom-test.xml
index 8fcfb10..d445527 100644
--- a/src/tests/antunit/componentbom-test.xml
+++ b/src/tests/antunit/componentbom-test.xml
@@ -22,8 +22,7 @@
   <checksum property="sha256hash" file="${antlib.location}" 
algorithm="SHA-256"/>
 
   <target name="testToolMetadataInJsonFormat">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.json"
+    <cdx:componentbom outputdirectory="${output}"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname">
         <file file="${antlib.location}"/>
@@ -56,8 +55,7 @@
   </target>
 
   <target name="testToolMetadataInXmlFormat">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname">
         <file file="${antlib.location}"/>
@@ -119,8 +117,7 @@
   </target>
 
   <target name="testSupplierAndManufacturerInMeta">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <manufacturer name="Example">
         <url url="https://example.org/"/>
@@ -148,7 +145,7 @@
         name="bom.metadata.supplier.url"
         value="https://example.com/"/>
 
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       useComponentSupplier="true"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname">
@@ -171,7 +168,7 @@
   <target name="testComponentIsRequired">
     <au:expectfailure expectedMessage="nested component element is required"
         xmlns:au="antlib:org.apache.ant.antunit">
-      <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+      <cdx:componentbom outputdirectory="${output}" format="xml"
                         xmlns:cdx="antlib:org.apache.ant.cyclonedx"/>
     </au:expectfailure>
   </target>
@@ -179,7 +176,7 @@
   <target name="testOnlyOneComponentIsPermitted">
     <au:expectfailure expectedMessage="only one nested component element is 
permitted"
         xmlns:au="antlib:org.apache.ant.antunit">
-      <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+      <cdx:componentbom outputdirectory="${output}" format="xml"
                         xmlns:cdx="antlib:org.apache.ant.cyclonedx">
         <component/>
         <component/>
@@ -190,7 +187,7 @@
   <target name="testComponentNameIsRequired">
     <au:expectfailure expectedMessage="component name is required"
         xmlns:au="antlib:org.apache.ant.antunit">
-      <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+      <cdx:componentbom outputdirectory="${output}" format="xml"
                         xmlns:cdx="antlib:org.apache.ant.cyclonedx">
         <component/>
       </cdx:componentbom>
@@ -198,8 +195,7 @@
   </target>
 
   <target name="testMinimalComponentData">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname"/>
     </cdx:componentbom>
@@ -215,8 +211,7 @@
   </target>
 
   <target name="testComponentTypeCanBeSet">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname" type="APPLICATION"/>
     </cdx:componentbom>
@@ -228,8 +223,7 @@
   </target>
 
   <target name="testCalculatesPurlAndBomRef">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname" group="org.example" version="1.0"/>
     </cdx:componentbom>
@@ -245,8 +239,7 @@
   </target>
 
   <target name="testPurlAndBomRefCanBeSet">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname" group="org.example" version="1.0"
                  purl="foo" bomRef="bar"/>
@@ -263,9 +256,8 @@
   </target>
 
   <target name="testMaximalComponentData">
-    <mkdir dir="${output}"/>
     <checksum property="ant.file.sha256" file="${ant.file}" 
algorithm="SHA-256"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname" group="org.example" version="1.0"
                  description="My Test Library">
@@ -325,8 +317,7 @@
   </target>
 
   <target name="testMinimalAdditionalComponentData">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname"/>
       <additionalComponent name="dependency" scope="OPTIONAL"/>
@@ -347,8 +338,7 @@
   </target>
 
   <target name="testDependencies">
-    <mkdir dir="${output}"/>
-    <cdx:componentbom bomfile="${output}/bom.xml" format="XML"
+    <cdx:componentbom outputdirectory="${output}" format="xml"
                       xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component name="testname" group="org.example" version="1.0">
         <dependency bomRef="pkg:maven/org.example/[email protected]?type=jar"/>
@@ -375,10 +365,10 @@
   </target>
 
   <target name="testAntlibsOwnBom">
-    <mkdir dir="${output}"/>
     <cdx:componentbom
-        bomfile="${output}/bom.json"
-        format="JSON"
+        bomName="ant-cyclonedx-${artifact.version}-cyclonedx"
+        outputdirectory="${output}"
+        format="all"
         useComponentSupplier="true"
         xmlns:cdx="antlib:org.apache.ant.cyclonedx">
       <component
@@ -423,55 +413,9 @@
           id="cyclonedx-core"
           unknownDependencies="true"/>
     </cdx:componentbom>
-    <copy todir="/tmp" file="${output}/bom.json"/>
-    <cdx:componentbom
-        bomfile="${output}/bom.xml"
-        format="XML"
-        useComponentSupplier="true"
-        xmlns:cdx="antlib:org.apache.ant.cyclonedx">
-      <component
-          name="ant-cyclonedx"
-          group="org.apache.ant"
-          version="${artifact.version}"
-          description="Apache CycloneDX Antlib"
-          manufacturerIsSupplier="true">
-        <file file="${antlib.location}"/>
-        <manufacturer name="Apache Ant Development Team">
-          <url url="https://ant.apache.org/"/>
-        </manufacturer>
-        <license licenseId="Apache-2.0"/>
-        <externalReference
-            type="VCS"
-            url="https://github.com/apache/ant-antlibs-cyclonedx"/>
-        <dependency componentRef="ant"/>
-        <dependency componentRef="cyclonedx-core"/>
-      </component>
-      <additionalComponent
-          name="ant"
-          group="org.apache.ant"
-          version="1.10.17"
-          isExternal="true"
-          unknownDependencies="true"
-          id="ant">
-        <manufacturer name="Apache Ant Development Team">
-          <url url="https://ant.apache.org/"/>
-        </manufacturer>
-        <license licenseId="Apache-2.0"/>
-        <externalReference
-            type="VCS"
-            url="https://github.com/apache/ant"/>
-        <externalReference
-            type="WEBSITE"
-            url="https://ant.apache.org/"/>
-      </additionalComponent>
-      <additionalComponent
-          name="cyclonedx-core-java"
-          group="org.cyclonedx"
-          version="12.1.0"
-          id="cyclonedx-core"
-          unknownDependencies="true"/>
-    </cdx:componentbom>
-    <copy todir="/tmp" file="${output}/bom.xml"/>
+    <copy todir="/tmp">
+      <fileset dir="${output}" includes="ant-cyclonedx*"/>
+    </copy>
   </target>
 
 </project>
diff --git a/src/tests/antunit/shared.xml b/src/tests/antunit/shared.xml
index 44ba1cd..744c407 100644
--- a/src/tests/antunit/shared.xml
+++ b/src/tests/antunit/shared.xml
@@ -32,6 +32,7 @@
         <pathelement location="${antlib.location}"/>
       </classpath>
     </typedef>
+    <mkdir dir="${output}"/>
   </target>
 
   <target name="tearDown">

Reply via email to