jshell-maven-plugin icon indicating copy to clipboard operation
jshell-maven-plugin copied to clipboard

How to let it known the maven project classpath

Open developerworks opened this issue 7 years ago • 7 comments
trafficstars

When i started with: mvn com.github.johnpoth:jshell-maven-plugin:1.0:run, it can not find the org.springframework.boot namespace with import command auto completion.

developerworks avatar Apr 16 '18 06:04 developerworks

Hi @developerworks, it doesn't seem JShell supports that? When adding JARs or modules on the class-path/module path, JShell doesn't seem to resolve anything with auto completion except when coming from the JDK (JFrame etc..). I'd be curious to know if you were able to achieve auto completion when launching JShell manually from the command line with classes not from the JDK ? Thanks!

johnpoth avatar Apr 16 '18 09:04 johnpoth

I found a solution: https://gist.github.com/jianwu/9b36a3c9b47edd9c2304ccbf9ace081b

developerworks avatar Apr 16 '18 11:04 developerworks

nice @developerworks ! Does this provide auto completion? The script seems to add the JAR dependencies to JShell's class-path which didn't provide auto completion for me. Thanks!

johnpoth avatar Apr 16 '18 11:04 johnpoth

In my case, the maven project is a springboot project, i imports something like this:

import org.springframework.web.util.*

But it does not provide you auto completion level by level.

jshell> /imports 
|    import java.io.*
|    import java.math.*
|    import java.net.*
|    import java.nio.file.*
|    import java.util.*
|    import java.util.concurrent.*
|    import java.util.function.*
|    import java.util.prefs.*
|    import java.util.regex.*
|    import java.util.stream.*
|    import org.springframework.web.util.*

import is successful.

jshell> import org.
ietf   jcp    omg    w3c    xml   

there is no springframework when type a TAB key.

Maybe, i need import parent packages. i try it.

developerworks avatar Apr 16 '18 11:04 developerworks

I tried, if a package have not any classes, no auto completion. leaf package(or have classes in it) is ok.

jshell> import org.springframework.web.util.
AbstractUriTemplateHandler      ContentCachingRequestWrapper    ContentCachingResponseWrapper   CookieGenerator                 DefaultUriBuilderFactory        
DefaultUriTemplateHandler       HtmlUtils                       HttpSessionMutexListener        IntrospectorCleanupListener     JavaScriptUtils                 
NestedServletException          ServletContextPropertyUtils     TagUtils                        UriBuilder                      UriBuilderFactory               
UriComponents                   UriComponentsBuilder            UriTemplate                     UriTemplateHandler              UriUtils                        
UrlPathHelper                   WebAppRootListener              WebUtils                        


developerworks avatar Apr 16 '18 11:04 developerworks

There's a known bug where jshell doesn't tab complete on non-jdk packages

https://bugs.openjdk.java.net/browse/JDK-8177650

thinkbigthings avatar Apr 16 '18 18:04 thinkbigthings

Thanks @thinkbigthings for the info! @developerworks don't think we can do much here until the bug is fixed...

johnpoth avatar Apr 17 '18 08:04 johnpoth