grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.79k stars 951 forks source link

Grails 7: Console and Cli rewrite for org.jline:jline:3.0.0-3.27.1 #13752

Open jamesfredley opened 1 month ago

jamesfredley commented 1 month ago

https://github.com/grails/grails-core/pull/13474 trigged this issue and it was resolved for now, by https://github.com/grails/grails-core/pull/13801#pullrequestreview-2386404521

https://mvnrepository.com/artifact/jline/jline/2.14.6 is not compatible with https://mvnrepository.com/artifact/org.fusesource.jansi/jansi/2.4.1

Moving to https://mvnrepository.com/artifact/org.jline/jline/3.0.0 - https://mvnrepository.com/artifact/org.jline/jline/3.27.1 will require a rewrite of:

grails.build.logging.GrailsConsole
grails.build.logging.GrailsEclipseConsole
org.grails.build.interactive.CandidateListCompletionHandler
org.grails.cli.GrailsCli
org.grails.cli.*.*

Issue description

org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 13.
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:65)
    at java.base@17.0.12/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base@17.0.12/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base@17.0.12/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base@17.0.12/java.lang.reflect.Method.invoke(Method.java:569)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)
    at jdk.proxy1/jdk.proxy1.$Proxy4.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:200)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:132)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:103)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:63)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:121)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
    at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: org.junit.platform.commons.JUnitException: TestEngine with ID 'spock' failed to discover tests
    at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)
    at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:132)
    at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:107)
    at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:78)
    at app//org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:99)
    at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:85)
    at app//org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:47)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:124)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:99)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:94)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)
    ... 18 more
Caused by: java.lang.NoSuchMethodError: 'java.io.OutputStream org.fusesource.jansi.AnsiConsole.wrapOutputStream(java.io.OutputStream)'
    at jline.AnsiWindowsTerminal.detectAnsiSupport(AnsiWindowsTerminal.java:57)
    at jline.AnsiWindowsTerminal.<init>(AnsiWindowsTerminal.java:27)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
    at java.base/java.lang.Class.newInstance(Class.java:645)
    at jline.TerminalFactory.getFlavor(TerminalFactory.java:205)
    at jline.TerminalFactory.create(TerminalFactory.java:96)
    at jline.TerminalFactory.get(TerminalFactory.java:180)
    at jline.TerminalFactory.get(TerminalFactory.java:186)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:244)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:236)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:228)
    at grails.build.logging.GrailsConsole.createConsoleReader(GrailsConsole.java:247)
    at grails.build.logging.GrailsConsole.initialize(GrailsConsole.java:183)
    at grails.build.logging.GrailsConsole.<init>(GrailsConsole.java:156)
    at grails.build.logging.GrailsConsole.createInstance(GrailsConsole.java:387)
    at grails.build.logging.GrailsConsole.getInstance(GrailsConsole.java:307)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1989)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3900)
    at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
    at grails.build.logging.GrailsConsoleSpec$_closure1.doCall(GrailsConsoleSpec.groovy:41)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:279)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1007)
    at groovy.lang.Closure.call(Closure.java:433)
    at groovy.lang.Closure.call(Closure.java:422)
    at org.spockframework.runtime.extension.builtin.ConditionalExtension.evaluateCondition(ConditionalExtension.java:124)
    at org.spockframework.runtime.extension.builtin.ConditionalExtension.evaluateCondition(ConditionalExtension.java:112)
    at org.spockframework.runtime.extension.builtin.ConditionalExtension.visitSpecAnnotation(ConditionalExtension.java:58)
    at org.spockframework.runtime.extension.IAnnotationDrivenExtension.visitSpecAnnotations(IAnnotationDrivenExtension.java:40)
    at org.spockframework.runtime.ExtensionRunner.doRunAnnotationDrivenExtensions(ExtensionRunner.java:124)
    at org.spockframework.runtime.ExtensionRunner.doRunAnnotationDrivenExtensions(ExtensionRunner.java:114)
    at org.spockframework.runtime.ExtensionRunner.runAnnotationDrivenExtensions(ExtensionRunner.java:65)
    at org.spockframework.runtime.ExtensionRunner.runAnnotationDrivenExtensions(ExtensionRunner.java:54)
    at org.spockframework.runtime.ExtensionRunner.run(ExtensionRunner.java:44)
    at org.spockframework.runtime.SpockEngineDiscoveryPostProcessor.processSpecNode(SpockEngineDiscoveryPostProcessor.java:52)
    at org.spockframework.runtime.SpockEngineDiscoveryPostProcessor.lambda$postProcessEngineDescriptor$0(SpockEngineDiscoveryPostProcessor.java:16)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
    at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
    at org.spockframework.runtime.SpockEngineDiscoveryPostProcessor.postProcessEngineDescriptor(SpockEngineDiscoveryPostProcessor.java:17)
    at org.spockframework.runtime.SpockEngine.discover(SpockEngine.java:31)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)
    ... 28 more
matrei commented 1 month ago

@jamesfredley Where are you getting this error?

jamesfredley commented 1 month ago

@matrei I was before https://github.com/grails/grails-core/pull/13801#pullrequestreview-2386404521. I also ran into it back when consolidating the versions into gradle.properties and went with jansi 1.18 then as well, due to this error.

jansi:2.0.0-2.4.1 all trigger it with jline:jline:2.14.6

I think https://github.com/grails/grails-core/pull/13805#issuecomment-2432326411 would help avoid OS specific situations when apply updates from dependabot.

codeconsole commented 3 days ago

Jline 3.27.1 is the current version.

implementation "org.jline:jline:3.27.1"

https://github.com/jline/jline3

t's definitely not a drop-in replacement. During development, I haven't considered compatibility as a goal at all, so I changed a lot of APIs. The package have been renamed, a lot of new interfaces have been introduced for various features (Parser, Highlighter...). The completers have changed also to support description, coloring, complete/incomplete, with one main difference is that the completers can return all possibilities, as the console reader will find matching candidates within that list. Obtaining a terminal can be done using:

  Terminal terminal = TerminalBuilder.builder()
              // further customization
              .builder();
And the reader using:
   LineReader reader = LineReader.builder()
             .terminal(terminal)
              // further customization
             .build();

Reading lines is done in the same way using the various readLine() methods. https://groups.google.com/g/jline-users/c/ebQxEFUVkKs

More upgrade discussion: https://groups.google.com/g/jline-users/c/PEWgDPSOUt4/m/2qU63kgWDAAJ