Skip to content

Commit

Permalink
Merge pull request #15843 from aloubyansky/processed-groupIds
Browse files Browse the repository at this point in the history
Added processGroupIds parameter to generate-platform-descriptor-json goal
  • Loading branch information
gsmet authored Mar 19, 2021
2 parents 5573dcb + 0d40436 commit 231b5ec
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 31 deletions.
7 changes: 3 additions & 4 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@
<execution>
<phase>${pluginPhase}</phase>
<goals>
<!-- goal>generate-extensions-json</goal -->
<goal>generate-platform-descriptor-json</goal>
</goals>
<configuration>
<ignoredGroupIds>
<ignoredGroupId>software.amazon.awssdk</ignoredGroupId>
</ignoredGroupIds>
<processGroupIds>
<groupId>io.quarkus</groupId>
</processGroupIds>
<bomArtifactId>quarkus-bom</bomArtifactId>
<resolveDependencyManagement>true</resolveDependencyManagement>
<overridesFile>${basedir}/target/resources/catalog-overrides.json</overridesFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> processGroupIds = new HashSet<>(1);

/**
* Skips the check for the descriptor's artifactId naming convention
*/
Expand Down Expand Up @@ -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())
Expand All @@ -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 (processGroupIds.isEmpty()) {
if (ignoredGroupIds.contains(artifact.getGroupId())) {
continue;
}
} else if (!processGroupIds.contains(artifact.getGroupId())) {
continue;
}

Expand Down Expand Up @@ -487,10 +506,6 @@ private List<Dependency> 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));
Expand All @@ -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)
Expand Down

0 comments on commit 231b5ec

Please sign in to comment.