Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix terminal usage in mvnd #1486

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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