diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangCatalogService.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangCatalogService.java index c28ce62985983..ea2f6b78ccef0 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangCatalogService.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangCatalogService.java @@ -40,6 +40,10 @@ public JBangCatalogService(boolean interactiveMode, MessageWriter output, String this.jbang = new JBangSupport(interactiveMode, output); } + public boolean ensureJBangIsInstalled() { + return jbang.ensureJBangIsInstalled(); + } + @Override public JBangCatalog readCatalog(Path path) { if (!jbang.isAvailable() && !jbang.isInstallable()) { @@ -93,8 +97,9 @@ public JBangCatalog readCombinedCatalog(Optional projectDir, Optional !aliases.containsKey(e.getKey())) diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangSupport.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangSupport.java index 047e5ba5252ef..852b5d1bdb901 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangSupport.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangSupport.java @@ -38,6 +38,7 @@ public class JBangSupport { private Path workingDirectory; private Optional installed = Optional.empty(); + private Optional version = Optional.empty(); public JBangSupport(boolean interactiveMode, MessageWriter output) { this(interactiveMode, output, Paths.get(System.getProperty("user.dir"))); @@ -138,8 +139,12 @@ public List execute(String... args) { } public Optional version() { - return execute("version").stream().findFirst(); - + if (version.isPresent()) { + return version; + } else { + version = execute("version").stream().findFirst(); + } + return version; } public boolean isAvailable() { diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginManager.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginManager.java index e3c4d1dd54e93..d230c9cabd3a7 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginManager.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/PluginManager.java @@ -238,7 +238,9 @@ private boolean reconcile(PluginCatalog catalog) { .orElseThrow(() -> new IllegalArgumentException("Unknwon plugin catalog location.")); List installedTypes = catalog.getPlugins().entrySet().stream().map(Map.Entry::getValue).map(Plugin::getType) .collect(Collectors.toList()); - Map installablePlugins = state.getInstallablePlugins().entrySet().stream() + //Let's only fetch installable plugins of the corresponding types. + //This will help us avoid uneeded calls to things like jbang if no jbang plugins are installed + Map installablePlugins = state.installablePlugins(installedTypes).entrySet().stream() .filter(e -> installedTypes.contains(e.getValue().getType())) .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); 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 f983ef6f7e02f..3e5f0c2573491 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 @@ -141,6 +141,7 @@ public Map getInstallablePlugins() { public Map jbangPlugins() { boolean isUserScoped = !projectRoot.isPresent(); Map jbangPlugins = new HashMap<>(); + jbangCatalogService.ensureJBangIsInstalled(); JBangCatalog jbangCatalog = jbangCatalogService.readCombinedCatalog(projectRoot, userHome); jbangCatalog.getAliases().forEach((location, alias) -> { String name = util.getName(location);