From d77462e78a13548792ca7fb3598c376babedb3d7 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Sat, 28 Sep 2024 20:51:07 +0200 Subject: [PATCH] [MNG-8261] Remove jline-terminal-ffm direct dependency (#1719) --- apache-maven/pom.xml | 10 +++++++- maven-embedder/pom.xml | 2 +- maven-jline/pom.xml | 24 ++++++++++++++++++- .../jline/JLineMessageBuilderFactory.java | 18 ++++++++++++-- pom.xml | 19 +++++++++++++-- 5 files changed, 66 insertions(+), 7 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 22395d9ef6..5648338578 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -99,7 +99,15 @@ under the License. org.jline - jline + jline-reader + + + org.jline + jline-terminal-jni + + + org.jline + jline-terminal-ffm diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 284d4e3d15..79bea30fcf 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -123,7 +123,7 @@ under the License. org.jline - jline + jansi-core diff --git a/maven-jline/pom.xml b/maven-jline/pom.xml index a63ae613aa..867bc34b41 100644 --- a/maven-jline/pom.xml +++ b/maven-jline/pom.xml @@ -40,7 +40,20 @@ under the License. org.jline - jline + jline-reader + + + org.jline + jline-terminal-jni + + + org.jline + jline-terminal-ffm + true + + + org.jline + jansi-core javax.inject @@ -62,4 +75,13 @@ under the License. + + + + org.eclipse.sisu + sisu-maven-plugin + + + + diff --git a/maven-jline/src/main/java/org/apache/maven/jline/JLineMessageBuilderFactory.java b/maven-jline/src/main/java/org/apache/maven/jline/JLineMessageBuilderFactory.java index de47d4b753..703a880423 100644 --- a/maven-jline/src/main/java/org/apache/maven/jline/JLineMessageBuilderFactory.java +++ b/maven-jline/src/main/java/org/apache/maven/jline/JLineMessageBuilderFactory.java @@ -74,7 +74,7 @@ public class JLineMessageBuilderFactory implements MessageBuilderFactory, Prompt @Override public String readLine() throws IOException { - return doPrompt(null, true); + return doPrompt(null, false); } @Override @@ -193,7 +193,21 @@ public class JLineMessageBuilderFactory implements MessageBuilderFactory, Prompt private String doPrompt(String message, boolean password) throws IOException { try { - return MessageUtils.reader.readLine(message != null ? message + ": " : null, password ? '*' : null); + if (message != null) { + if (!message.endsWith("\n")) { + if (message.endsWith(":")) { + message += " "; + } else if (!message.endsWith(": ")) { + message += ": "; + } + } + int lastNl = message.lastIndexOf('\n'); + String begin = message.substring(0, lastNl + 1); + message = message.substring(lastNl + 1); + MessageUtils.terminal.writer().print(begin); + MessageUtils.terminal.flush(); + } + return MessageUtils.reader.readLine(message, password ? '*' : null); } catch (Exception e) { throw new IOException("Unable to prompt user", e); } diff --git a/pom.xml b/pom.xml index 586b859116..23f0a79949 100644 --- a/pom.xml +++ b/pom.xml @@ -461,7 +461,22 @@ under the License. org.jline - jline + jline-reader + ${jlineVersion} + + + org.jline + jline-terminal-ffm + ${jlineVersion} + + + org.jline + jline-terminal-jni + ${jlineVersion} + + + org.jline + jansi-core ${jlineVersion} @@ -818,7 +833,7 @@ under the License. test - org.jline:jline + org.jline:jline-terminal-ffm