Skip to content

Commit

Permalink
Fix terminal usage in mvnd (#1486)
Browse files Browse the repository at this point in the history
mvnd needs to set its own terminal, so we need to open the door for that
  • Loading branch information
gnodet authored Apr 25, 2024
1 parent 854589b commit 8d6bf5f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.maven.jline;

import java.io.PrintStream;

import org.apache.maven.api.services.MessageBuilder;
import org.apache.maven.api.services.MessageBuilderFactory;
import org.jline.jansi.AnsiConsole;
Expand All @@ -37,18 +35,24 @@ public class MessageUtils {
static Thread shutdownHook;
static final Object STARTUP_SHUTDOWN_MONITOR = new Object();

static PrintStream prevOut;
static PrintStream prevErr;
public static void systemInstall(Terminal terminal) {
MessageUtils.terminal = terminal;
MessageUtils.reader = createReader(terminal);
}

public static void systemInstall() {
terminal = new FastTerminal(
() -> TerminalBuilder.builder().name("Maven").dumb(true).build(), t -> {
reader = LineReaderBuilder.builder().terminal(t).build();
AnsiConsole.setTerminal(t);
MessageUtils.terminal = new FastTerminal(
() -> TerminalBuilder.builder().name("Maven").dumb(true).build(), terminal -> {
MessageUtils.reader = createReader(terminal);
AnsiConsole.setTerminal(terminal);
AnsiConsole.systemInstall();
});
}

private static LineReader createReader(Terminal terminal) {
return LineReaderBuilder.builder().terminal(terminal).build();
}

public static void registerShutdownHook() {
if (shutdownHook == null) {
shutdownHook = new Thread(() -> {
Expand Down

0 comments on commit 8d6bf5f

Please sign in to comment.