From ea2d71c032ff05e84920006c05b6bb6e844be1a9 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 9 Jun 2021 09:49:09 +1000 Subject: [PATCH] Enable continuous testing from the IDE Also fix color logging --- .../quarkus/deployment/dev/IDEDevModeMain.java | 16 ++++++++++++---- .../io/quarkus/dev/console/QuarkusConsole.java | 6 +++++- .../io/quarkus/bootstrap/IDELauncherImpl.java | 4 ++++ .../quarkus/bootstrap/app/QuarkusBootstrap.java | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/IDEDevModeMain.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/IDEDevModeMain.java index 02d8dda3b9a0d..886771374c893 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/IDEDevModeMain.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/IDEDevModeMain.java @@ -3,7 +3,7 @@ import java.io.Closeable; import java.io.File; import java.nio.file.Path; -import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; @@ -24,6 +24,7 @@ import io.quarkus.bootstrap.util.PathsUtils; import io.quarkus.bootstrap.util.QuarkusModelHelper; import io.quarkus.bootstrap.utils.BuildToolHelper; +import io.quarkus.dev.spi.DevModeType; public class IDEDevModeMain implements BiConsumer>, Closeable { @@ -79,8 +80,11 @@ public void accept(CuratedApplication curatedApplication, Map st terminateIfRunning(); delegate = new IsolatedDevModeMain(); + Map params = new HashMap<>(); + params.put(DevModeContext.class.getName(), devModeContext); + params.put(DevModeType.class.getName(), DevModeType.LOCAL); delegate.accept(curatedApplication, - Collections.singletonMap(DevModeContext.class.getName(), devModeContext)); + params); } @Override @@ -107,6 +111,7 @@ private DevModeContext.ModuleInfo toModule(WorkspaceModule module) throws Bootst // Peek the first one as we assume that it is the primary resourceDirectory = module.getSourceSet().getResourceDirectories().iterator().next().toString(); } + return new DevModeContext.ModuleInfo.Builder() .setAppArtifactKey(key) .setName(module.getArtifactCoords().getArtifactId()) @@ -121,7 +126,6 @@ private DevModeContext.ModuleInfo toModule(WorkspaceModule module) throws Bootst } private DevModeContext.ModuleInfo toModule(LocalProject project) { - return new DevModeContext.ModuleInfo.Builder() .setAppArtifactKey(project.getKey()) .setName(project.getArtifactId()) @@ -135,6 +139,10 @@ private DevModeContext.ModuleInfo toModule(LocalProject project) { .collect(Collectors.toCollection(LinkedHashSet::new)))) .setSourceParents(PathsCollection.of(project.getSourcesDir())) .setPreBuildOutputDir(project.getCodeGenOutputDir().toString()) - .setTargetDir(project.getOutputDir().toString()).build(); + .setTargetDir(project.getOutputDir().toString()) + .setTestSourcePaths(PathsCollection.of(project.getTestSourcesSourcesDir())) + .setTestClassesPath(project.getTestClassesDir().toAbsolutePath().toString()) + .setTestResourcesOutputPath(project.getTestClassesDir().toAbsolutePath().toString()) + .setTestResourcePaths(PathsCollection.from(project.getTestResourcesSourcesDirs())).build(); } } diff --git a/core/devmode-spi/src/main/java/io/quarkus/dev/console/QuarkusConsole.java b/core/devmode-spi/src/main/java/io/quarkus/dev/console/QuarkusConsole.java index 8d79acfe4d866..eb22b834fa06d 100644 --- a/core/devmode-spi/src/main/java/io/quarkus/dev/console/QuarkusConsole.java +++ b/core/devmode-spi/src/main/java/io/quarkus/dev/console/QuarkusConsole.java @@ -6,6 +6,8 @@ public abstract class QuarkusConsole { + public static final String LAUNCHED_FROM_IDE = "io.quarkus.launched-from-ide"; + public static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows"); /** @@ -38,7 +40,9 @@ public abstract class QuarkusConsole { private volatile boolean started = false; public static boolean hasColorSupport() { - + if (Boolean.getBoolean(LAUNCHED_FROM_IDE)) { + return true; //assume the IDE run window has color support + } if (IS_WINDOWS) { // On Windows without a known good emulator // TODO: optimally we would check if Win32 getConsoleMode has diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java index d8b51186fe22a..f3f9a3b07cd03 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java @@ -26,7 +26,11 @@ */ public class IDELauncherImpl implements Closeable { + public static final String LAUNCHED_FROM_IDE = "io.quarkus.launched-from-ide"; + public static Closeable launch(Path classesDir, Map context) { + System.setProperty(LAUNCHED_FROM_IDE, "true"); + System.setProperty("quarkus.test.basic-console", "true"); //IDE's don't support raw mode final Path projectDir = BuildToolHelper.getProjectDir(classesDir); if (projectDir == null) { throw new IllegalStateException("Failed to locate project dir for " + classesDir); diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/QuarkusBootstrap.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/QuarkusBootstrap.java index b8956b5dbfcda..59352c6a3fa9d 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/QuarkusBootstrap.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/QuarkusBootstrap.java @@ -426,7 +426,7 @@ public Builder setAuxiliaryApplication(boolean auxiliaryApplication) { return this; } - public Builder setLocalProjectDiscovery(boolean localProjectDiscovery) { + public Builder setLocalProjectDiscovery(Boolean localProjectDiscovery) { this.localProjectDiscovery = localProjectDiscovery; return this; }