From 4132df53d98d1f4e87737bcf0692aa1775a721d0 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Wed, 8 Mar 2023 09:22:08 +0100 Subject: [PATCH] Generate a Maven profile in the platform containing config to generate SBOMs --- .../platformgen/GeneratePlatformProjectMojo.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/io/quarkus/bom/decomposer/maven/platformgen/GeneratePlatformProjectMojo.java b/maven-plugin/src/main/java/io/quarkus/bom/decomposer/maven/platformgen/GeneratePlatformProjectMojo.java index d47f7e04..4a706be7 100644 --- a/maven-plugin/src/main/java/io/quarkus/bom/decomposer/maven/platformgen/GeneratePlatformProjectMojo.java +++ b/maven-plugin/src/main/java/io/quarkus/bom/decomposer/maven/platformgen/GeneratePlatformProjectMojo.java @@ -268,7 +268,9 @@ public void execute() throws MojoExecutionException, MojoFailureException { } if (dependenciesToBuild != null) { - generateDepsToBuildModule(pom); + generateDepsToBuildModule(pom, "quarkus-dependencies-to-build", "depsToBuild", "dependencies-to-build", + "-deps-to-build.txt"); + generateDepsToBuildModule(pom, "quarkus-sbom", "sbom", "sbom", "-sbom.json"); } if (platformConfig.getGenerateMavenRepoZip() != null) { @@ -318,9 +320,9 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } - private void generateDepsToBuildModule(Model parentPom) throws MojoExecutionException { + private void generateDepsToBuildModule(Model parentPom, String artifactId, String profileId, String outputDirName, + String outputFileSuffix) throws MojoExecutionException { final Model pom = newModel(); - final String artifactId = "quarkus-dependencies-to-build"; pom.setArtifactId(artifactId); pom.setPackaging(ArtifactCoords.TYPE_POM); pom.setName(getNameBase(parentPom) + " " + artifactIdToName(artifactId)); @@ -346,13 +348,13 @@ private void generateDepsToBuildModule(Model parentPom) throws MojoExecutionExce plugin.setArtifactId(pluginDescriptor().getArtifactId()); Profile profile = new Profile(); - profile.setId("depsToBuild"); + profile.setId(profileId); pom.addProfile(profile); final Activation activation = new Activation(); profile.setActivation(activation); final ActivationProperty ap = new ActivationProperty(); activation.setProperty(ap); - ap.setName("depsToBuild"); + ap.setName(profileId); build = new Build(); profile.setBuild(build); @@ -373,7 +375,7 @@ private void generateDepsToBuildModule(Model parentPom) throws MojoExecutionExce } build.setDefaultGoal(sb.toString()); - Path outputDir = buildDir.toPath().resolve("dependencies-to-build"); + Path outputDir = buildDir.toPath().resolve(outputDirName); final String prefix = pomXml.toPath().getParent().relativize(outputDir).toString(); for (PlatformMemberImpl m : members.values()) { if (m.config.isHidden() || !m.config.isEnabled()) { @@ -390,7 +392,7 @@ private void generateDepsToBuildModule(Model parentPom) throws MojoExecutionExce m.generatedBomCoords().getGroupId() + ":" + m.generatedBomCoords().getArtifactId() + ":" + getDependencyVersion(pom, m.descriptorCoords()))); config.addChild( - textDomElement("outputFile", prefix + "/" + m.generatedBomCoords().getArtifactId() + "-deps-to-build.txt")); + textDomElement("outputFile", prefix + "/" + m.generatedBomCoords().getArtifactId() + outputFileSuffix)); final ProjectDependencyFilterConfig depsToBuildConfig = m.config().getDependenciesToBuild(); if (depsToBuildConfig != null) {