From 09ff13b266fbfe6f83dca6a17b7a9ea00ad12afd Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 4 Apr 2023 13:48:04 +0300 Subject: [PATCH] Provide an actionable console item for missing DevUI Closes: #32334 --- .../deployment/console/ConsoleProcessor.java | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleProcessor.java index b7fb567f528c7b..cc42e1fc9af4ca 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleProcessor.java @@ -1,5 +1,8 @@ package io.quarkus.deployment.console; +import static io.quarkus.deployment.dev.testing.MessageFormat.RED; +import static io.quarkus.deployment.dev.testing.MessageFormat.RESET; + import java.io.File; import java.nio.file.Path; import java.util.ArrayList; @@ -18,6 +21,8 @@ import org.eclipse.microprofile.config.ConfigProvider; import org.jboss.logging.Logger; +import io.quarkus.deployment.Capabilities; +import io.quarkus.deployment.Capability; import io.quarkus.deployment.IsDevelopment; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -43,7 +48,8 @@ public class ConsoleProcessor { private static final Logger log = Logger.getLogger(ConsoleProcessor.class); private static boolean consoleInstalled = false; - static volatile ConsoleStateManager.ConsoleContext context; + static volatile ConsoleStateManager.ConsoleContext exceptionsConsoleContext; + static volatile ConsoleStateManager.ConsoleContext devUIConsoleContext; /** * Installs the interactive console for continuous testing (and other usages) @@ -85,6 +91,37 @@ ConsoleInstalledBuildItem setupConsole(TestConfig config, return ConsoleInstalledBuildItem.INSTANCE; } + @Consume(ConsoleInstalledBuildItem.class) + @Produce(ServiceStartBuildItem.class) + @BuildStep + void missingDevUIMessageHandler(Capabilities capabilities) { + if (capabilities.isPresent(Capability.VERTX_HTTP)) { + return; + } + + if (devUIConsoleContext == null) { + devUIConsoleContext = ConsoleStateManager.INSTANCE.createContext("HTTP"); + } + devUIConsoleContext.reset(new ConsoleCommand('d', "Dev UI", new ConsoleCommand.HelpState(new Supplier() { + @Override + public String get() { + return MessageFormat.RED; + } + }, new Supplier() { + @Override + public String get() { + return "unavailable"; + } + }), new Runnable() { + @Override + public void run() { + System.out.println("\n" + RED + + "For a Quarkus application to have access to the DevUI, it needs to directly or transitively include the 'quarkus-vertx-http' extension" + + RESET + "\n"); + } + })); + } + @Consume(ConsoleInstalledBuildItem.class) @BuildStep void setupExceptionHandler(BuildProducer exceptionNotificationBuildItem, @@ -100,11 +137,11 @@ public void accept(Throwable throwable, StackTraceElement stackTraceElement) { lastUserCode.set(stackTraceElement); } })); - if (context == null) { - context = ConsoleStateManager.INSTANCE.createContext("Exceptions"); + if (exceptionsConsoleContext == null) { + exceptionsConsoleContext = ConsoleStateManager.INSTANCE.createContext("Exceptions"); } - context.reset( + exceptionsConsoleContext.reset( new ConsoleCommand('x', "Open last exception in IDE", new ConsoleCommand.HelpState(new Supplier() { @Override public String get() {