diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginManagerUtil.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginManagerUtil.java index 8690e18156e8e..76316f83bcda6 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginManagerUtil.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginManagerUtil.java @@ -2,11 +2,16 @@ import java.net.URL; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.quarkus.maven.dependency.ArtifactKey; import io.quarkus.maven.dependency.GACTV; +import io.quarkus.registry.catalog.Extension; public class PluginManagerUtil { @@ -95,6 +100,29 @@ public String getName(Optional gactv, Optional url, Optional p .orElseThrow(() -> new IllegalStateException("Could not determinate name for location.")); } + /** + * Collect all the transitive dependencies of the specified artifact. + * + * @param artifactKey the artifact key + * @param allExtensions all the extensions + * @return the set of transitive dependencies + */ + public static List getTransitives(ArtifactKey artifactKey, Map allExtensions) { + Extension extension = allExtensions.get(artifactKey); + Map metadata = extension.getMetadata(); + List result = new ArrayList<>(); + + if (metadata.get("extension-dependencies") instanceof List extensionDependencies) { + for (Object extensionDependency : extensionDependencies) { + if (extensionDependency instanceof String artifactCoords) { + ArtifactKey k = ArtifactKey.fromString(artifactCoords); + result.add(k); + } + } + } + return result; + } + private String stripCliSuffix(String s) { Matcher m = CLI_SUFFIX.matcher(s); if (m.find()) { diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginMangerState.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginMangerState.java index c973ed066b01d..71abd3b42c2fa 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginMangerState.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginMangerState.java @@ -1,14 +1,15 @@ package io.quarkus.cli.plugin; import static io.quarkus.cli.plugin.PluginManagerUtil.ALIAS_SEPARATOR; +import static io.quarkus.cli.plugin.PluginManagerUtil.getTransitives; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -173,11 +174,18 @@ public Map extensionPlugins() { Map extensionPlugins = new HashMap<>(); projectRoot.map(r -> quarkusProject.get()).ifPresent(project -> { try { - Set installed = project.getExtensionManager().getInstalled().stream() - .map(ArtifactCoords::getKey).collect(Collectors.toSet()); - for (Extension e : project.getExtensionsCatalog().getExtensions()) { - if (installed.contains(e.getArtifact().getKey())) { - for (String cliPlugin : ExtensionProcessor.getCliPlugins(e)) { + Map allExtensions = new HashMap<>(); + project.getExtensionsCatalog().getExtensions().forEach(e -> allExtensions.put(e.getArtifact().getKey(), e)); + + for (ArtifactCoords artifactCoords : project.getExtensionManager().getInstalled()) { + ArtifactKey artifactKey = artifactCoords.getKey(); + List allKeys = new ArrayList<>(); + allKeys.add(artifactKey); + allKeys.addAll(getTransitives(artifactKey, allExtensions)); + + for (ArtifactKey key : allKeys) { + Extension extension = allExtensions.get(key); + for (String cliPlugin : ExtensionProcessor.getCliPlugins(extension)) { Plugin plugin = cliPlugin.contains(ALIAS_SEPARATOR) ? util.fromAlias(cliPlugin) : util.fromLocation(cliPlugin); extensionPlugins.put(plugin.getName(), plugin);