Skip to content

Commit

Permalink
Enable continuous testing from the IDE
Browse files Browse the repository at this point in the history
Also fix color logging
  • Loading branch information
stuartwdouglas committed Jun 8, 2021
1 parent 1871e8e commit ea2d71c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<CuratedApplication, Map<String, Object>>, Closeable {

Expand Down Expand Up @@ -79,8 +80,11 @@ public void accept(CuratedApplication curatedApplication, Map<String, Object> st

terminateIfRunning();
delegate = new IsolatedDevModeMain();
Map<String, Object> 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
Expand All @@ -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())
Expand All @@ -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())
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");

/**
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ea2d71c

Please sign in to comment.