[MNG-8261] Remove jline-terminal-ffm direct dependency (#1719)

This commit is contained in:
Guillaume Nodet 2024-09-28 20:51:07 +02:00 committed by GitHub
parent 2d224623a3
commit d77462e78a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 66 additions and 7 deletions

View File

@ -99,7 +99,15 @@ under the License.
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<artifactId>jline-reader</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jni</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-ffm</artifactId>
</dependency>
<!-- DI Runtime -->

View File

@ -123,7 +123,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<artifactId>jansi-core</artifactId>
</dependency>
<dependency>

View File

@ -40,7 +40,20 @@ under the License.
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<artifactId>jline-reader</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jni</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-ffm</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jansi-core</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
@ -62,4 +75,13 @@ under the License.
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -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);
}

19
pom.xml
View File

@ -461,7 +461,22 @@ under the License.
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<artifactId>jline-reader</artifactId>
<version>${jlineVersion}</version>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-ffm</artifactId>
<version>${jlineVersion}</version>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jni</artifactId>
<version>${jlineVersion}</version>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jansi-core</artifactId>
<version>${jlineVersion}</version>
</dependency>
<dependency>
@ -818,7 +833,7 @@ under the License.</licenseText>
<ignoredScope>test</ignoredScope>
</ignoredScopes>
<excludes>
<exclude>org.jline:jline</exclude>
<exclude>org.jline:jline-terminal-ffm</exclude>
</excludes>
</enforceBytecodeVersion>
</rules>