From d7ce612f5ad5e69201d4ea6e075d1ca49b6ed0e1 Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Fri, 26 Jun 2020 16:48:59 +0200 Subject: [PATCH] Fixup #10279 use AppArtifactKey instead of a string in ExtensionDescriptorMojo --- .../maven/ExtensionDescriptorMojo.java | 60 ++++++------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java b/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java index 75d0de4c0ea9b..2ba76397c6ba2 100644 --- a/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java +++ b/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java @@ -11,6 +11,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import io.quarkus.bootstrap.BootstrapConstants; import io.quarkus.bootstrap.model.AppArtifactCoords; +import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.bootstrap.model.AppModel; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -268,11 +269,13 @@ private void validateExtensionDeps() throws MojoExecutionException { final AppArtifactCoords deploymentCoords = AppArtifactCoords.fromString(deployment); - final String rootDeploymentGact = gact(deploymentCoords); + final AppArtifactKey rootDeploymentGact = deploymentCoords.getKey(); final Node rootDeployment = new Node(null, rootDeploymentGact, 2); - final Node rootRuntime = rootDeployment.newChild(gact(project.getArtifact()), 1); + final Artifact artifact = project.getArtifact(); + final Node rootRuntime = rootDeployment.newChild(new AppArtifactKey(artifact.getGroupId(), artifact.getArtifactId(), + artifact.getClassifier(), artifact.getType()), 1); - final Map expectedExtensionDeps = new HashMap<>(); + final Map expectedExtensionDeps = new HashMap<>(); expectedExtensionDeps.put(rootDeploymentGact, rootDeployment); expectedExtensionDeps.put(rootRuntime.gact, rootRuntime); // collect transitive extension deps @@ -315,7 +318,7 @@ public boolean visitEnter(DependencyNode node) { + BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT + " property in its " + BootstrapConstants.DESCRIPTOR_PATH); } - currentNode = currentNode.newChild(gact(AppArtifactCoords.fromString(deploymentStr)), + currentNode = currentNode.newChild(AppArtifactCoords.fromString(deploymentStr).getKey(), currentNodeId); expectedExtensionDeps.put(currentNode.gact, currentNode); extDepsTotal.incrementAndGet(); @@ -353,7 +356,8 @@ public boolean visitEnter(DependencyNode dep) { if (artifact == null) { return true; } - final Node node = expectedExtensionDeps.get(gact(artifact)); + final Node node = expectedExtensionDeps.get(new AppArtifactKey(artifact.getGroupId(), artifact.getArtifactId(), + artifact.getClassifier(), artifact.getExtension())); if (node != null && !node.included) { node.included = true; extDepsTotal.decrementAndGet(); @@ -372,12 +376,12 @@ public boolean visitLeave(DependencyNode node) { log.error("Quarkus Extension Dependency Verification Error"); log.error("Deployment artifact " + deploymentCoords + " was found to be missing dependencies on Quarkus extension artifacts marked with '-' below:"); - final List missing = rootDeployment.collectMissing(log); + final List missing = rootDeployment.collectMissing(log); final StringBuilder buf = new StringBuilder(); buf.append("Deployment artifact "); buf.append(deploymentCoords); buf.append(" is missing the following dependencies from its configuration: "); - final Iterator i = missing.iterator(); + final Iterator i = missing.iterator(); buf.append(i.next()); while (i.hasNext()) { buf.append(", ").append(i.next()); @@ -484,62 +488,32 @@ private ObjectMapper getMapper(boolean yaml) { } } - static String gact(AppArtifactCoords artifact) { - StringBuilder buf = new StringBuilder(); - buf.append(artifact.getGroupId()).append(':').append(artifact.getArtifactId()).append(':'); - final String classifier = artifact.getClassifier(); - if (classifier != null && !classifier.isEmpty()) { - buf.append(classifier); - } - return buf.append(':').append(artifact.getType()).append(':').toString(); - } - - static String gact(Artifact artifact) { - StringBuilder buf = new StringBuilder(); - buf.append(artifact.getGroupId()).append(':').append(artifact.getArtifactId()).append(':'); - final String classifier = artifact.getClassifier(); - if (classifier != null && !classifier.isEmpty()) { - buf.append(classifier); - } - return buf.append(':').append(artifact.getType()).append(':').toString(); - } - - static String gact(org.eclipse.aether.artifact.Artifact artifact) { - StringBuilder buf = new StringBuilder(); - buf.append(artifact.getGroupId()).append(':').append(artifact.getArtifactId()).append(':'); - final String classifier = artifact.getClassifier(); - if (classifier != null && !classifier.isEmpty()) { - buf.append(classifier); - } - return buf.append(':').append(artifact.getExtension()).append(':').toString(); - } - private static class Node { final Node parent; - final String gact; + final AppArtifactKey gact; final int id; boolean included; List children = new ArrayList<>(0); - Node(Node parent, String gact, int id) { + Node(Node parent, AppArtifactKey gact, int id) { this.parent = parent; this.gact = gact; this.id = id; } - Node newChild(String gact, int id) { + Node newChild(AppArtifactKey gact, int id) { final Node child = new Node(this, gact, id); children.add(child); return child; } - List collectMissing(Log log) { - final List missing = new ArrayList<>(); + List collectMissing(Log log) { + final List missing = new ArrayList<>(); collectMissing(log, 0, missing); return missing; } - private void collectMissing(Log log, int depth, List missing) { + private void collectMissing(Log log, int depth, List missing) { final StringBuilder buf = new StringBuilder(); if (included) { buf.append('+');