Skip to content

Commit

Permalink
Try some maven startup tweaks (#79 improves #44)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Feb 13, 2023
2 parents e532426 + 622cf13 commit e78a22e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
6 changes: 5 additions & 1 deletion plugin-maven/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format.

## [Unreleased]

### Fixed
- More attempts to improve maven IDE launch experience. ([#79](https://github.com/equodev/equo-ide/pull/79) fixes [#44](https://github.com/equodev/equo-ide/issues/44))
- mac already works great
- linux now has a `sleep 5`
- windows now has a visible cmd prompt console
## [0.13.1] - 2023-02-12
### Fixed
- No more errors on filesystems which don't support atomic move. ([#73](https://github.com/equodev/equo-ide/pull/73))
Expand Down
4 changes: 4 additions & 0 deletions plugin-maven/src/main/java/dev/equo/ide/maven/LaunchMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package dev.equo.ide.maven;

import com.diffplug.common.swt.os.OS;
import dev.equo.ide.BuildPluginIdeMain;
import dev.equo.ide.IdeHook;
import dev.equo.ide.IdeHookBranding;
Expand Down Expand Up @@ -139,6 +140,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
ideHooks.add(welcomeHook);
}

if (!OS.getNative().isMac()) {
System.setProperty("equo-ide-maven-workarounds", "true");
}
caller.ideHooks = ideHooks;
caller.classpath = files;
caller.debugClasspath = debugClasspath;
Expand Down
13 changes: 9 additions & 4 deletions solstice/src/main/java/dev/equo/ide/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public static int launchAndInheritIO(
builder.directory(cwd);
}
var process = builder.start();
var outPumper = new StreamPumper(process.getInputStream(), System.out);
var errPumper = new StreamPumper(process.getErrorStream(), System.err);
var outPumper = new StreamPumper(process, process.getInputStream(), System.out);
var errPumper = new StreamPumper(process, process.getErrorStream(), System.err);
if (monitorProcess != null) {
new Thread(
() -> {
Expand All @@ -104,10 +104,12 @@ public static int launchAndInheritIO(
}

static class StreamPumper extends Thread {
private final Process process;
private final InputStream in;
private final PrintStream out;

private StreamPumper(InputStream in, PrintStream out) {
private StreamPumper(Process process, InputStream in, PrintStream out) {
this.process = process;
this.in = in;
this.out = out;
start();
Expand All @@ -123,7 +125,10 @@ public void run() {
out.flush();
}
} catch (IOException e) {
throw new RuntimeException(e);
if (process.isAlive()) {
// only report the exception if the process is alive
throw new RuntimeException(e);
}
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions solstice/src/main/java/dev/equo/ide/ScriptExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ private void exec(boolean isSeparate, @Nullable Consumer<Process> monitorProcess
}
}

private static boolean mavenWorkarounds() {
return "true".equals(System.getProperty("equo-ide-maven-workarounds"));
}

/** The integer value which marks that a process exited successfully. */
private static final int EXIT_VALUE_SUCCESS = 0;

Expand Down Expand Up @@ -167,7 +171,11 @@ private static List<String> getPlatformCmds(File scriptFile, boolean isSeparate)
// use sh to execute
if (isSeparate) {
File spawningScript =
createSelfDeletingScript("nohup " + quote(scriptFile) + " &" + "\n" + "disown");
createSelfDeletingScript(
""
+ ("nohup " + quote(scriptFile) + " &\n")
+ (mavenWorkarounds() ? "sleep 5\n" : "")
+ "disown\n");
return List.of("/bin/bash", spawningScript.getAbsolutePath());
} else {
return List.of("/bin/bash", scriptFile.getAbsolutePath());
Expand All @@ -181,7 +189,7 @@ private static File createInvisibleVbs(boolean isSeparate) throws IOException {
".vbs",
(file, printer) -> {
// args are at http://ss64.com/vb/run.html
String windowStyle = "0";
String windowStyle = mavenWorkarounds() ? "1" : "0";
String waitOnReturn = isSeparate ? "False" : "True";
// open the shell
printer.println(
Expand Down

0 comments on commit e78a22e

Please sign in to comment.