Skip to content

Commit

Permalink
Generate a Maven profile in the platform containing config to generat…
Browse files Browse the repository at this point in the history
…e SBOMs
  • Loading branch information
aloubyansky committed Mar 8, 2023
1 parent e8cb76b commit 4132df5
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand All @@ -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()) {
Expand All @@ -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) {
Expand Down

0 comments on commit 4132df5

Please sign in to comment.