Repository navigation
Upgrade JLine to 3.30.6 and Jansi to 2.4.2 - #15367
Conversation
There was a problem hiding this comment.
Pull request overview
This PR upgrades JLine from version 2.14.6 to 3.27.1 and Jansi from 1.18 to 2.4.1, requiring a comprehensive migration of all CLI-related code to the JLine 3 API. The changes address Java 24 compatibility warnings related to restricted method calls in the legacy Jansi version.
Changes:
- Updated JLine dependency from
jline:jline:2.14.6toorg.jline:jline:3.27.1and Jansi from1.18to2.4.1 - Migrated console infrastructure from JLine 2 API (
ConsoleReader,Terminal,Completer) to JLine 3 API (LineReader,Terminal,Completer) - Retained JLine 2 as a transitional dependency for Groovy 4.x's groovysh module compatibility, marked with TODO comments for removal when upgrading to Groovy 5
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| dependencies.gradle | Updates JLine version to 3.27.1, Jansi to 2.4.1, adds jline2 version variable for backward compatibility |
| grails-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java | Migrates from JLine 2 ConsoleReader to JLine 3 LineReader, updates terminal creation and history handling |
| grails-bootstrap/src/main/groovy/grails/build/logging/GrailsEclipseConsole.java | Updates terminal creation to use JLine 3 TerminalBuilder |
| grails-bootstrap/src/main/groovy/org/grails/build/interactive/CandidateListCompletionHandler.java | Converts from JLine 2 CompletionHandler to JLine 3 Completer interface |
| grails-shell-cli/src/main/groovy/org/grails/cli/GrailsCli.groovy | Updates interactive mode handling, terminal access, and history navigation for JLine 3 |
| grails-shell-cli/src/main/groovy/org/grails/cli/profile/commands/*.groovy | Updates all command completers to use JLine 3 Completer signature with Candidate objects |
| grails-shell-cli/src/main/groovy/org/grails/cli/interactive/completers/*.{java,groovy} | Migrates all completer implementations to JLine 3 API, replacing CharSequence with Candidate |
| grails-shell-cli/src/test/groovy/org/grails/cli/interactive/completers/RegexCompletorSpec.groovy | Updates tests to use JLine 3 API with ParsedLine and Candidate |
| grails-console/build.gradle, gradle/docs-dependencies.gradle | Adds both JLine 3 and JLine 2 dependencies with TODO comments |
| build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/SbomPlugin.groovy | Updates license mapping for JLine 3.27.1 to BSD-3-Clause |
| Multiple build.gradle files | Updates JLine dependency references from jline:jline to org.jline:jline |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
958bfea to
5d68523
Compare
5d68523 to
57e5cbe
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 36 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #13752 - Update jline from 2.14.6 to 3.30.6 (org.jline:jline) - Update jansi from 1.18 to 2.4.2 - Migrate all CLI code from JLine 2 API to JLine 3 API: - ConsoleReader -> LineReader/Terminal - jline.console.completer.Completer -> org.jline.reader.Completer - complete(buffer, cursor, candidates) -> complete(reader, line, candidates) - CharSequence candidates -> Candidate objects - Keep JLine 2 (jline:jline:2.14.6) for groovy-groovysh compatibility (Groovy 4.x groovysh requires JLine 2; Groovy 5.x uses JLine 3) - Add TODO comments for JLine 2 removal when upgrading to Groovy 5 - Add JLine 3.30.6 license mapping in SbomPlugin (BSD-3-Clause) - Update RegexCompletorSpec tests for JLine 3 API - Fix history handling to properly attach to LineReader - Fix completion candidates to use full names instead of suffixes - Remove unused imports and fields - Use AggregateCompleter to support multiple completers - Fix readLine method signature for JLine 3 API - Sync jansi version in grails-forge to 2.4.2
57e5cbe to
b4e78a0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 36 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 44 out of 44 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GrailsConsole improvements: - Use updateCompleter() with LineReaderImpl.setCompleter() instead of rebuilding the entire LineReader when completers are added - Add dedicated initializeHistory() method that properly attaches DefaultHistory to the LineReader after construction - CandidateListCompletionHandler: Auto-complete common prefix in buffer GrailsCli improvements: - Replace manual terminal attribute manipulation and input polling with JLine 3's native Terminal.Signal.INT handler for CTRL+C cancellation - This is the idiomatic way to handle interrupts in JLine 3 Test coverage: - Add comprehensive tests for GrailsConsole completer management - Add tests for CandidateListCompletionHandler - Add tests for all CLI completers: StringsCompleter, RegexCompletor, ClosureCompleter, SortedAggregateCompleter, EscapingFileNameCompletor, SimpleOrFileNameCompletor, and CommandCompleter
2074cbf to
d86a398
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 44 out of 44 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jdaugherty
left a comment
There was a problem hiding this comment.
I looked it over and then had AI look it over. This is a little out of my expertise but I think these comments seem relevant so I've added them.
| reader.drawLine(); | ||
| String current = line != null ? line.word() : ""; | ||
| if (current == null) { | ||
| current = ""; |
There was a problem hiding this comment.
In JLine 3, Completer.complete() is expected to contribute Candidates and let LineReader handle buffer updates. Writing suffix directly into reader.getBuffer() and forcing a redraw here bypasses that flow and can lead to double insertion or redraw glitches when the reader applies completion itself.
Can this class be reduced to candidate production only, with the common-prefix behavior handled by JLine's normal completion machinery?
|
|
||
| System.setProperty(ShutdownHooks.JLINE_SHUTDOWNHOOK, "false"); | ||
|
|
||
| if (isInteractiveEnabled()) { |
There was a problem hiding this comment.
Behavior change from 8.0.x: interactive mode now always calls createTerminal(), so grails.console.enable.terminal=false is no longer honored on the interactive path. If that property is still meant to disable terminal activation in headless or embedded environments, this branch probably needs to stay conditional.
| } | ||
|
|
||
| Terminal.SignalHandler previousHandler = null | ||
| try { |
There was a problem hiding this comment.
Regression from 8.0.x: the old loop canceled on both Ctrl+C and Esc (KEYPRESS_CTRL_C and KEYPRESS_ESC), but this version only hooks Terminal.Signal.INT. That means Esc no longer stops a running interactive command.
If Esc cancellation is still intended, this path needs equivalent handling or a regression test documenting the change.
| if (!historyIterator.hasNext()) { | ||
| console.error('! not valid. Can not repeat without history') | ||
| return false | ||
| } |
There was a problem hiding this comment.
Potential ! regression: this unconditionally skips the newest history entry, assuming the current ! command has already been persisted. If JLine 3 has not added ! to history at this point, foo, bar, ! will replay foo instead of bar.
Worth adding a regression test for that exact sequence.
| 'pkg:maven/org.antlr/[email protected]?type=jar' : 'BSD-3-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205 | ||
| 'pkg:maven/jline/[email protected]?type=jar' : 'BSD-2-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205 | ||
| 'pkg:maven/org.jline/[email protected]?type=jar' : 'BSD-2-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205 | ||
| 'pkg:maven/org.jline/[email protected]?type=jar' : 'BSD-3-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205 |
There was a problem hiding this comment.
Why do we have 2 different 3.x versions? Shouldn't there only be one.
Changes addressing review commentsMerged latest Fixes for jdaugherty's review (#4087092200)1. CandidateListCompletionHandler.java - Remove direct buffer manipulation Removed 2. GrailsConsole.java - Restore Restored the 3. GrailsCli.groovy - Restore Esc key cancellation Added 4. GrailsCli.groovy - Fix Rewrote 5. SbomPlugin.groovy - Remove stale JLine 3.23.0 license mapping Removed the |
- CandidateListCompletionHandler: Remove direct buffer/redraw manipulation; let JLine 3 LineReader handle completion display - GrailsConsole: Restore isActivateTerminal() conditional so grails.console.enable.terminal=false is honored in interactive mode - GrailsCli: Restore Esc key cancellation alongside Ctrl+C signal - GrailsCli: Fix ! history replay to skip all !-prefixed entries rather than blindly skipping one entry - SbomPlugin: Remove stale JLine 3.23.0 license mapping - Update CandidateListCompletionHandlerSpec for new behavior Assisted-by: Claude Code <[email protected]>
✅ All tests passed ✅🏷️ Commit: 9f923a4 Learn more about TestLens at testlens.app. |
jdaugherty
left a comment
There was a problem hiding this comment.
I'm assuming you launched the console to retest, otherwise LGTM
End-to-End CLI / Console Build + Smoke Test ResultsBranch tested: pr-15367 @ Tests - ALL PASSED
Builds - ALL SUCCEEDED
Smoke Tests - ALL PASSED (exit 0)
JLine 3 Runtime Verification
Notes
VerdictPR is functionally correct. All CLIs and consoles build and run with JLine 3 / Jansi 2. No regressions detected. Assisted-by: claude-code:claude-opus-4-7 |
…sions After merging 8.0.x (PR #15367 JLine 3 / Jansi 2 upgrade) into the Groovy 5 branch, two issues caused cyclonedxBom failures across 12 modules: 1. The main org.jline:jline artifact resolves to 3.30.6 (declared by jline.version in dependencies.gradle), not the stale 3.23.0 entry that the PR branch carried over from a prior merge. Updated the license override key from @3.23.0 to @3.30.6. 2. The other org.jline:* artifacts (jansi, jline-reader, jline-terminal, jline-builtins, jline-console, jline-style, jline-native, and the jline-terminal-{jansi,jna,jni} drivers) are pulled in transitively via Groovy 5's groovy-groovysh and resolve to 3.30.9. They are kept at @3.30.9 (not 3.30.6) since cyclonedx records the actual resolved coordinate, and Gradle does not reconcile across distinct artifact names. Comments on each entry now document this asymmetry so future jline bumps know which lines move with jline.version and which move with the groovy-groovysh transitive resolution. Verified by running `./gradlew assemble -PskipTests` end-to-end on JDK 21 (1292 tasks, 0 failures) on Windows. Assisted-by: sisyphus:claude-opus-4-7
Summary
Closes #13752
This PR upgrades JLine from 2.14.6 to 3.30.6 and Jansi from 1.18 to 2.4.2, migrating all CLI code to the JLine 3 API.
Commits
Changes
Dependency Updates
jline.version:2.14.6→3.30.6(noworg.jline:jline)jansi.version:1.18→2.4.2jline2.version: '2.14.6'for Groovy 4.x compatibilityJLine 3 Migration
jline.console.ConsoleReadertoorg.jline.reader.LineReader/org.jline.terminal.TerminalCompleterimplementations to use new signature:complete(LineReader, ParsedLine, List<Candidate>)CharSequencecandidates withCandidateobjectsTerminalBuilder"dumb".equals(terminal.getType())AggregateCompleterto support multiple completers in GrailsConsolePerformance & UX Improvements
updateCompleter()instead of rebuilding LineReader when adding completersGroovy 4.x Compatibility
jline:jline:2.14.6) as a dependency forgroovy-groovyshcompatibilityjline.*vsorg.jline.*)Files Modified
grails-bootstrap,grails-shell-cli,grails-console,grails-gradle/model, and build configurationNew Test Coverage (~100+ test cases)
New Test Specifications:
StringsCompleterSpec- 20+ tests for string-based completion (edge cases, unicode, special characters)SortedAggregateCompleterSpec- 10 tests for aggregate completer functionalityClosureCompleterSpec- 8 tests for closure-based completion (lazy evaluation, caching)EscapingFileNameCompletorSpec- 10 tests for file name completion with whitespace escapingSimpleOrFileNameCompletorSpec- 12 tests for combined fixed options + file completionCommandCompleterSpec- 12 tests for command completion delegationCandidateListCompletionHandlerSpec- 20+ tests for completion handler and common prefix detectionGrailsConsoleCompleterSpec- 15+ tests for console completer managementEnhanced Existing Tests:
RegexCompletorSpec- Added 10+ edge case tests for regex-based completionTesting Verification
classes,test,installDist,grails-gradle build,grails-forge classesStats