mirror of
https://github.com/apple/pkl.git
synced 2026-06-07 14:22:49 +02:00
Update JLine to 4.x (#1511)
- Remove dependency org.fusesource.jansi:jansi - In 4.x, org.fusesource.jansi:jansi was replaced with org.jline:jansi. Instead of adding this new dependency, this commit replaces Pkl’s single Jansi usage with custom code that preserves existing behavior. Fixing existing ANSI quirks is left for a future PR. - Replace jline-terminal-ansi with jline-terminal-jni - In 4.x, only -jni and -ffm are available (-ffm requires Java 22+) - Configure native-image build for jline-terminal-jni As updating JLine is delicate, I manually tested `pkl repl` and `jpkl repl` on Windows 11 (using Windows Terminal) and on Ubuntu, and found no issues. However, I do not have access to a macOS machine.
This commit is contained in:
@@ -119,6 +119,8 @@ abstract class NativeImageBuild : DefaultTask() {
|
||||
add("--initialize-at-build-time=")
|
||||
// needed for messagepack-java (see https://github.com/msgpack/msgpack-java/issues/600)
|
||||
add("--initialize-at-run-time=org.msgpack.core.buffer.DirectBufferAccess")
|
||||
// needed for jline-terminal-jni
|
||||
add("--initialize-at-run-time=org.jline.nativ,org.jline.terminal.impl.jni")
|
||||
add("--no-fallback")
|
||||
add("-H:IncludeResources=org/pkl/core/stdlib/.*\\.pkl")
|
||||
add("-H:IncludeResources=org/jline/utils/.*")
|
||||
|
||||
@@ -26,11 +26,8 @@ graalVmSha256-windows-x64 = "fde83c5ceec2c75560c747ccd9f314f90e4cf5c5287416e67c4
|
||||
ideaExtPlugin = "1.4.1"
|
||||
javaPoet = "0.+"
|
||||
javaxInject = "1"
|
||||
jansi = "2.+"
|
||||
jimfs = "1.+"
|
||||
# later versions don't work with native image
|
||||
# (at least not without additional configuration; tested with 3.25.1 and 3.27.1)
|
||||
jline = "3.23.0"
|
||||
jline = "4.+"
|
||||
jmh = "1.+"
|
||||
jmhPlugin = "0.7.3"
|
||||
jsr305 = "3.+"
|
||||
@@ -73,11 +70,10 @@ graalSdk = { group = "org.graalvm.sdk", name = "graal-sdk", version.ref = "graal
|
||||
graalJs = { group = "org.graalvm.js", name = "js", version.ref = "graalVm" }
|
||||
javaPoet = { group = "com.palantir.javapoet", name = "javapoet", version.ref = "javaPoet" }
|
||||
javaxInject = { group = "javax.inject", name = "javax.inject", version.ref = "javaxInject" }
|
||||
jansi = { group = "org.fusesource.jansi", name = "jansi", version.ref = "jansi" }
|
||||
jimfs = { group = "com.google.jimfs", name = "jimfs", version.ref = "jimfs" }
|
||||
jlineReader = { group = "org.jline", name = "jline-reader", version.ref = "jline" }
|
||||
jlineTerminal = { group = "org.jline", name = "jline-terminal", version.ref = "jline" }
|
||||
jlineTerminalJansi = { group = "org.jline", name = "jline-terminal-jansi", version.ref = "jline" }
|
||||
jlineTerminalJni = { group = "org.jline", name = "jline-terminal-jni", version.ref = "jline" }
|
||||
jsr305 = { group = "com.google.code.findbugs", name = "jsr305", version.ref = "jsr305" }
|
||||
junitApi = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
|
||||
junitEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
|
||||
|
||||
@@ -80,7 +80,6 @@ org.eclipse.jetty:jetty-servlets:11.0.26=testCompileClasspath,testImplementation
|
||||
org.eclipse.jetty:jetty-util:11.0.26=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-webapp:11.0.26=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-xml:11.0.26=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.fusesource.jansi:jansi:2.4.3=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.polyglot:polyglot:25.0.1=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.sdk:collections:25.0.1=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.sdk:graal-sdk:25.0.1=compileClasspath,compileOnlyDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testRuntimeClasspath
|
||||
@@ -120,10 +119,10 @@ org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3=swiftExportClasspathResol
|
||||
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinInternalAbiValidation,kotlinKlibCommonizerClasspath,nativeImageClasspath,runtimeClasspath,swiftExportClasspathResolvable,testCompileClasspath,testRuntimeClasspath
|
||||
org.jetbrains:markdown-jvm:0.7.3=nativeImageClasspath,runtimeClasspath,testRuntimeClasspath
|
||||
org.jetbrains:markdown:0.7.3=nativeImageClasspath,runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-native:3.23.0=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jline:jline-reader:3.23.0=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jline:jline-terminal-jansi:3.23.0=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jline:jline-terminal:3.23.0=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jline:jline-native:4.0.11=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jline:jline-reader:4.0.11=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jline:jline-terminal-jni:4.0.11=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jline:jline-terminal:4.0.11=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jspecify:jspecify:1.0.0=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.junit.jupiter:junit-jupiter-engine:6.0.3=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,10 +56,9 @@ dependencies {
|
||||
api(projects.pklCommonsCli)
|
||||
|
||||
implementation(projects.pklCommons)
|
||||
implementation(libs.jansi)
|
||||
implementation(libs.jlineReader)
|
||||
implementation(libs.jlineTerminal)
|
||||
implementation(libs.jlineTerminalJansi)
|
||||
implementation(libs.jlineTerminalJni)
|
||||
implementation(projects.pklServer)
|
||||
implementation(projects.pklFormatter)
|
||||
implementation(libs.clikt)
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.net.URI
|
||||
import java.nio.file.Path
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.io.path.deleteIfExists
|
||||
import org.fusesource.jansi.Ansi
|
||||
import org.jline.reader.EndOfFileException
|
||||
import org.jline.reader.Highlighter
|
||||
import org.jline.reader.LineReader
|
||||
@@ -52,7 +51,7 @@ class PklHighlighter : Highlighter {
|
||||
}
|
||||
|
||||
internal class Repl(workingDir: Path, private val server: ReplServer, private val color: Boolean) {
|
||||
private val terminal = TerminalBuilder.builder().apply { jansi(true) }.build()
|
||||
private val terminal = TerminalBuilder.builder().apply { jni(true) }.build()
|
||||
private val history = DefaultHistory()
|
||||
private val reader =
|
||||
LineReaderBuilder.builder()
|
||||
@@ -249,14 +248,20 @@ internal class Repl(workingDir: Path, private val server: ReplServer, private va
|
||||
}
|
||||
|
||||
private fun highlight(str: String): String {
|
||||
val ansi = Ansi.ansi()
|
||||
var normal = true
|
||||
// Inserting ANSI codes into a string that may already contain ANSI codes is problematic.
|
||||
// This code preserves existing behavior but should eventually be removed.
|
||||
val builder = StringBuilder()
|
||||
var bold = false
|
||||
for (part in str.split("`", "```")) {
|
||||
ansi.a(part)
|
||||
normal = !normal
|
||||
if (!normal) ansi.bold() else ansi.boldOff()
|
||||
if (bold) {
|
||||
builder.append("\u001B[1m")
|
||||
builder.append(part)
|
||||
builder.append("\u001B[22m")
|
||||
} else {
|
||||
builder.append(part)
|
||||
}
|
||||
bold = !bold
|
||||
}
|
||||
ansi.reset()
|
||||
return ansi.toString()
|
||||
return builder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ io.leangen.geantyref:geantyref:1.3.16=runtimeClasspath,testRuntimeClasspath
|
||||
net.java.dev.jna:jna:5.14.0=runtimeClasspath,testRuntimeClasspath
|
||||
org.commonmark:commonmark-ext-gfm-tables:0.28.0=runtimeClasspath,testRuntimeClasspath
|
||||
org.commonmark:commonmark:0.28.0=runtimeClasspath,testRuntimeClasspath
|
||||
org.fusesource.jansi:jansi:2.4.3=runtimeClasspath,testRuntimeClasspath
|
||||
org.graalvm.polyglot:polyglot:25.0.1=runtimeClasspath,testRuntimeClasspath
|
||||
org.graalvm.sdk:collections:25.0.1=runtimeClasspath,testRuntimeClasspath
|
||||
org.graalvm.sdk:graal-sdk:25.0.1=runtimeClasspath,testRuntimeClasspath
|
||||
@@ -54,10 +53,10 @@ org.jetbrains:annotations:13.0=compileClasspath,testCompileClasspath
|
||||
org.jetbrains:annotations:23.0.0=runtimeClasspath,testRuntimeClasspath
|
||||
org.jetbrains:markdown-jvm:0.7.3=runtimeClasspath,testRuntimeClasspath
|
||||
org.jetbrains:markdown:0.7.3=runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-native:3.23.0=runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-reader:3.23.0=runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-terminal-jansi:3.23.0=runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-terminal:3.23.0=runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-native:4.0.11=runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-reader:4.0.11=runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-terminal-jni:4.0.11=runtimeClasspath,testRuntimeClasspath
|
||||
org.jline:jline-terminal:4.0.11=runtimeClasspath,testRuntimeClasspath
|
||||
org.msgpack:msgpack-core:0.9.11=runtimeClasspath,testRuntimeClasspath
|
||||
org.organicdesign:Paguro:3.10.3=runtimeClasspath,testRuntimeClasspath
|
||||
org.snakeyaml:snakeyaml-engine:2.10=runtimeClasspath,testRuntimeClasspath
|
||||
|
||||
Reference in New Issue
Block a user