From 966836925397998c9db8902edcf5159c3d875fd5 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Thu, 18 Mar 2021 13:07:52 +0100 Subject: [PATCH] Added processedGroupIds parameter to generate-platform-descriptor-json goal --- devtools/bom-descriptor-json/pom.xml | 7 +- .../GeneratePlatformDescriptorJsonMojo.java | 67 +++++++++++-------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/devtools/bom-descriptor-json/pom.xml b/devtools/bom-descriptor-json/pom.xml index 348d3c8d8f245..49f11ce14cb70 100644 --- a/devtools/bom-descriptor-json/pom.xml +++ b/devtools/bom-descriptor-json/pom.xml @@ -48,13 +48,12 @@ ${pluginPhase} - generate-platform-descriptor-json - - software.amazon.awssdk - + + io.quarkus + quarkus-bom true ${basedir}/target/resources/catalog-overrides.json diff --git a/devtools/platform-descriptor-json-plugin/src/main/java/io/quarkus/maven/GeneratePlatformDescriptorJsonMojo.java b/devtools/platform-descriptor-json-plugin/src/main/java/io/quarkus/maven/GeneratePlatformDescriptorJsonMojo.java index b90c02ece37fb..20141e62ee235 100644 --- a/devtools/platform-descriptor-json-plugin/src/main/java/io/quarkus/maven/GeneratePlatformDescriptorJsonMojo.java +++ b/devtools/platform-descriptor-json-plugin/src/main/java/io/quarkus/maven/GeneratePlatformDescriptorJsonMojo.java @@ -108,12 +108,21 @@ public class GeneratePlatformDescriptorJsonMojo extends AbstractMojo { private MavenProjectHelper projectHelper; /** - * Group ID's that we know don't contain extensions. This can speed up the process - * by preventing the download of artifacts that are not required. + * A set of artifact group ID's that should be excluded from of the BOM and the descriptor. + * This can speed up the process by preventing the download of artifacts that are not required. */ @Parameter private Set ignoredGroupIds = new HashSet<>(0); + /** + * A set of group IDs artifacts of which should be checked to be extensions and if so, included into the + * generated descriptor. If this parameter is configured, artifacts with group IDs that aren't found + * among the configured set will be ignored. However, this will not prevent extensions that are inherited + * from parent platforms with different group IDs to be included into the generated descriptor. + */ + @Parameter + private Set processedGroupIds = new HashSet<>(1); + /** * Skips the check for the descriptor's artifactId naming convention */ @@ -246,6 +255,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { for (Dependency dep : deps) { final Artifact artifact = dep.getArtifact(); + // checking whether the descriptor is present in the BOM if (!skipBomCheck && !jsonFoundInBom) { jsonFoundInBom = artifact.getArtifactId().equals(jsonArtifact.getArtifactId()) && artifact.getGroupId().equals(jsonArtifact.getGroupId()) @@ -254,11 +264,20 @@ public void execute() throws MojoExecutionException, MojoFailureException { && artifact.getVersion().equals(jsonArtifact.getVersion()); } - if (ignoredGroupIds.contains(artifact.getGroupId()) - || !artifact.getExtension().equals("jar") + // filtering non jar artifacts + if (!artifact.getExtension().equals("jar") || "javadoc".equals(artifact.getClassifier()) || "tests".equals(artifact.getClassifier()) - || "sources".equals(artifact.getClassifier())) { + || "sources".equals(artifact.getClassifier()) + || artifact.getArtifactId().endsWith("-deployment")) { + continue; + } + + if (processedGroupIds.isEmpty()) { + if (ignoredGroupIds.contains(artifact.getGroupId())) { + continue; + } + } else if (!processedGroupIds.contains(artifact.getGroupId())) { continue; } @@ -487,10 +506,6 @@ private List readDependencyManagement(Path pomXml) throws MojoExecut } private JsonExtension processDependency(Artifact artifact) throws IOException { - return processDependencyToObjectNode(artifact); - } - - private JsonExtension processDependencyToObjectNode(Artifact artifact) throws IOException { final Path path = artifact.getFile().toPath(); if (Files.isDirectory(path)) { return processMetaInfDir(artifact, path.resolve(BootstrapConstants.META_INF)); @@ -517,30 +532,28 @@ private JsonExtension processMetaInfDir(Artifact artifact, Path metaInfDir) if (!Files.exists(metaInfDir)) { return null; } - Path jsonOrYaml = null; Path yaml = metaInfDir.resolve(BootstrapConstants.QUARKUS_EXTENSION_FILE_NAME); if (Files.exists(yaml)) { mapper = getMapper(true); - jsonOrYaml = yaml; - } else { - mapper = getMapper(false); - Path json = metaInfDir.resolve(BootstrapConstants.EXTENSION_PROPS_JSON_FILE_NAME); - if (!Files.exists(json)) { - final Path props = metaInfDir.resolve(BootstrapConstants.DESCRIPTOR_FILE_NAME); - if (Files.exists(props)) { - final JsonExtension e = new JsonExtension(); - e.setArtifact(new ArtifactCoords(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), - artifact.getExtension(), artifact.getVersion())); - e.setName(artifact.getArtifactId()); - return e; - } - return null; - } else { - jsonOrYaml = json; + return processPlatformArtifact(artifact, yaml, mapper); + } + + JsonExtension e = null; + mapper = getMapper(false); + Path json = metaInfDir.resolve(BootstrapConstants.EXTENSION_PROPS_JSON_FILE_NAME); + if (!Files.exists(json)) { + final Path props = metaInfDir.resolve(BootstrapConstants.DESCRIPTOR_FILE_NAME); + if (Files.exists(props)) { + e = new JsonExtension(); + e.setArtifact(new ArtifactCoords(artifact.getGroupId(), artifact.getArtifactId(), + artifact.getClassifier(), artifact.getExtension(), artifact.getVersion())); + e.setName(artifact.getArtifactId()); } + } else { + e = processPlatformArtifact(artifact, json, mapper); } - return processPlatformArtifact(artifact, jsonOrYaml, mapper); + return e; } private JsonExtension processPlatformArtifact(Artifact artifact, Path descriptor, ObjectMapper mapper)