Skip to content

Conversation

@jamesfredley
Copy link
Contributor

@jamesfredley jamesfredley commented Jan 30, 2026

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

  1. Upgrade JLine to 3.30.6 and Jansi to 2.4.2 - Core migration of all JLine 2 code to JLine 3 API
  2. Add comprehensive test coverage for JLine 3 completers - ~100+ new test cases for completer functionality
  3. Improve LineReader completer updates and CTRL+C handling - Performance and UX improvements

Changes

Dependency Updates

  • jline.version: 2.14.63.30.6 (now org.jline:jline)
  • jansi.version: 1.182.4.2
  • Added jline2.version: '2.14.6' for Groovy 4.x compatibility

JLine 3 Migration

  • Migrated from jline.console.ConsoleReader to org.jline.reader.LineReader / org.jline.terminal.Terminal
  • Updated all Completer implementations to use new signature: complete(LineReader, ParsedLine, List<Candidate>)
  • Replaced CharSequence candidates with Candidate objects
  • Updated terminal creation to use TerminalBuilder
  • Fixed history handling to properly attach to LineReader via builder
  • Fixed completion candidates to use full names (flags, profiles, features)
  • Fixed dumb terminal detection using "dumb".equals(terminal.getType())
  • Implemented AggregateCompleter to support multiple completers in GrailsConsole

Performance & UX Improvements

  • Efficient completer updates: Use updateCompleter() instead of rebuilding LineReader when adding completers
  • Auto-complete common prefix: CandidateListCompletionHandler now auto-completes the common prefix in the buffer
  • Improved CTRL+C handling: Better cancellation support during command execution by masking terminal interrupt and polling for keypress

Groovy 4.x Compatibility

  • Retained JLine 2 (jline:jline:2.14.6) as a dependency for groovy-groovysh compatibility
  • Groovy 4.x's groovysh module still requires JLine 2
  • Both JLine versions coexist (different package namespaces: jline.* vs org.jline.*)
  • Added TODO comments marking JLine 2 dependencies for removal when upgrading to Groovy 5

Files Modified

  • 44 files across grails-bootstrap, grails-shell-cli, grails-console, grails-gradle/model, and build configuration

New 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 functionality
  • ClosureCompleterSpec - 8 tests for closure-based completion (lazy evaluation, caching)
  • EscapingFileNameCompletorSpec - 10 tests for file name completion with whitespace escaping
  • SimpleOrFileNameCompletorSpec - 12 tests for combined fixed options + file completion
  • CommandCompleterSpec - 12 tests for command completion delegation
  • CandidateListCompletionHandlerSpec - 20+ tests for completion handler and common prefix detection
  • GrailsConsoleCompleterSpec - 15+ tests for console completer management

Enhanced Existing Tests:

  • RegexCompletorSpec - Added 10+ edge case tests for regex-based completion

Testing Verification

  • All existing tests pass
  • All new tests pass (102 tests in grails-shell-cli, 100+ in grails-bootstrap)
  • Checkstyle and CodeNarc pass
  • Build verified: classes, test, installDist, grails-gradle build, grails-forge classes

Stats

44 files changed, 2703 insertions(+), 352 deletions(-)

Copilot AI review requested due to automatic review settings January 30, 2026 23:57
@jamesfredley jamesfredley self-assigned this Jan 30, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.6 to org.jline:jline:3.27.1 and Jansi from 1.18 to 2.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.

@jamesfredley jamesfredley force-pushed the issue-13752-upgrade-jansi-jline branch from 958bfea to 5d68523 Compare January 31, 2026 00:09
@jamesfredley jamesfredley changed the title Upgrade JLine to 3.27.1 and Jansi to 2.4.1 Upgrade JLine to 3.30.6 and Jansi to 2.4.2 Jan 31, 2026
@jamesfredley jamesfredley force-pushed the issue-13752-upgrade-jansi-jline branch from 5d68523 to 57e5cbe Compare January 31, 2026 00:24
@jamesfredley jamesfredley linked an issue Jan 31, 2026 that may be closed by this pull request
@jamesfredley jamesfredley requested a review from Copilot January 31, 2026 00:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jamesfredley jamesfredley marked this pull request as ready for review January 31, 2026 03:44
@jamesfredley jamesfredley added the relates-to:v8 Grails 8 label Feb 3, 2026
@jamesfredley jamesfredley moved this to In Progress in Apache Grails Feb 5, 2026
@jamesfredley jamesfredley added this to the grails:8.0.0-M1 milestone Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Console and Cli rewrite for org.jline:jline:3.0.0-3.27.1+

1 participant