Skip to content

Commit

Permalink
Added processedGroupIds parameter to generate-platform-descriptor-jso…
Browse files Browse the repository at this point in the history
…n goal
  • Loading branch information
aloubyansky committed Mar 18, 2021
1 parent 5aea757 commit 9668369
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>
<processedGroupIds>
<groupId>io.quarkus</groupId>
</processedGroupIds>
<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> processedGroupIds = 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 (processedGroupIds.isEmpty()) {
if (ignoredGroupIds.contains(artifact.getGroupId())) {
continue;
}
} else if (!processedGroupIds.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 9668369

Please sign in to comment.