Skip to content

Commit d001542

Browse files
committed
distribution-intake external reference is more accurate
this fixes #245 Signed-off-by: Hervé Boutemy <hboutemy@apache.org>
1 parent fa5541d commit d001542

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/main/java/org/cyclonedx/maven/DefaultModelConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ private void extractComponentMetadata(MavenProject project, Component component,
232232
if (project.getDistributionManagement() != null) {
233233
addExternalReference(ExternalReference.Type.DISTRIBUTION, project.getDistributionManagement().getDownloadUrl(), component);
234234
if (project.getDistributionManagement().getRepository() != null) {
235-
addExternalReference(ExternalReference.Type.DISTRIBUTION, project.getDistributionManagement().getRepository().getUrl(), component);
235+
ExternalReference.Type type =
236+
(schemaVersion.getVersion() < 1.5) ? ExternalReference.Type.DISTRIBUTION : ExternalReference.Type.DISTRIBUTION_INTAKE;
237+
addExternalReference(type, project.getDistributionManagement().getRepository().getUrl(), component);
236238
}
237239
}
238240
if (project.getIssueManagement() != null) {

src/test/java/org/cyclonedx/maven/ExternalReferenceTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,23 @@ private static void verifyParentExternalReferences(File projDir) {
5151
assertExternalReferences(bomJsonFile, "chat", "url", singleton("https://acme.com/parent"));
5252
assertExternalReferences(bomJsonFile, "website", "url", singleton("https://cyclonedx.org/acme"));
5353
assertExternalReferences(bomJsonFile, "vcs", "url", singleton("https://github.com/CycloneDX/cyclonedx-maven-plugin.git"));
54-
verifyCommonExternalReferences(bomJsonFile);
54+
verifyCommonExternalReferences(bomJsonFile, false);
5555
}
5656

5757
private static void verifyChildExternalReferences(File projDir) {
5858
File bomJsonFile = new File(projDir, "child/target/bom.json");
5959
assertExternalReferences(bomJsonFile, "chat", "url", asList("https://acme.com/parent", "https://acme.com/child"));
6060
assertExternalReferences(bomJsonFile, "website", "url", singleton("https://cyclonedx.org/acme/child"));
6161
assertExternalReferences(bomJsonFile, "vcs", "url", singleton("https://github.com/CycloneDX/cyclonedx-maven-plugin.git/child"));
62-
verifyCommonExternalReferences(bomJsonFile);
62+
verifyCommonExternalReferences(bomJsonFile, true);
6363
}
6464

65-
private static void verifyCommonExternalReferences(File bomJsonFile) {
65+
private static void verifyCommonExternalReferences(File bomJsonFile, boolean child) {
6666
assertExternalReferences(bomJsonFile, "chat", "comment", singleton("optional comment"));
6767
assertExternalReferences(bomJsonFile, "release-notes", "url", singleton("https://github.com/CycloneDX/cyclonedx-maven-plugin/releases"));
6868
assertExternalReferences(bomJsonFile, "build-system", "url", singleton("https://github.com/CycloneDX/cyclonedx-maven-plugin/actions"));
69-
assertExternalReferences(bomJsonFile, "distribution", "url", singleton("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"));
69+
// CycloneDX 1.4 supports distribution only, 1.5 replaces with distribution-intake
70+
assertExternalReferences(bomJsonFile, child ? "distribution" : "distribution-intake", "url", singleton("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"));
7071
assertExternalReferences(bomJsonFile, "issue-tracker", "url", singleton("https://github.com/CycloneDX/cyclonedx-maven-plugin/issues"));
7172
assertExternalReferences(bomJsonFile, "mailing-list", "url", singleton("https://dev.ml.cyclonedx.org/archive"));
7273
}

src/test/resources/external-reference/child/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<artifactId>cyclonedx-maven-plugin</artifactId>
2929
<version>${cyclonedx-maven-plugin.version}</version>
3030
<configuration>
31+
<schemaVersion>1.4</schemaVersion>
3132
<externalReferences combine.children="append">
3233
<externalReference>
3334
<type>CHAT</type>

0 commit comments

Comments
 (0)