Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:jshell task :classes not found, be sure to compile the project first #4

Closed
toonvanacker opened this issue Jun 18, 2020 · 11 comments
Closed
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@toonvanacker
Copy link

Even when running

./gradlew --console plain classes jshell

I still get the message

:jshell task :classes not found, be sure to compile the project first

I haven't been able to figure out what could be causing this. Could you point me in the right direction?

I'm using Java 13.0.1 and Gradle 6.5 on macOS Catalina (10.15.4).

@mrsarm
Copy link
Owner

mrsarm commented Jun 18, 2020

@toonvanacker don't worry about that, the plugins always check whether it can execute the classes task, and it doesn't know that you already passed the task explicitly in the command line.

I should add a check to avoid the warning, but what I'm trying to say is that the message does not mean that the classes task was not executed, it is that the jshell task couldn't find it querying the Gradle API, but because you passed it explicitly, it was for sure executed (check the output to be sure).

@toonvanacker
Copy link
Author

Thank you for the quick response!

I mistook this warning for the root issue then. I should have been clearer from the start: my main issue is that JShell immediately exits, like so:

$ ./gradlew --console plain classes jshell
> Task :compileJava UP-TO-DATE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE

> Task :jshellSetup
:jshell task :classes not found, be sure to compile the project first

> Task :jshell
|  Welcome to JShell -- Version 13.0.1
|  For an introduction type: /help intro

BUILD SUCCESSFUL in 1s
3 actionable tasks: 2 executed, 1 up-to-date
$ 

I'm using some Java 13 preview features, but I'm not sure if that would be at all related.

@mrsarm
Copy link
Owner

mrsarm commented Jun 18, 2020

🤔 checking your output, the JShell console is executed, but intermediately terminated but no clues why:

> Task :jshell
|  Welcome to JShell -- Version 13.0.1
|  For an introduction type: /help intro

Could you try again as follow? execute the classes task before execute the jshell one, in two separates executions, actually there is no need to execute both in the same Gradle execution:

$ ./gradlew classes
$ ./gradlew --console plain jshell

If it does the same, the last instruction pleace add the -q argument: ./gradlew --console plain -q jshell.

Also, what unix shell are you running? Bash? or an alternative like Zsh? If the last, could you please execute it within a Bash console? just execute in your Zsh console bash and you will enter into a new "bash" console session inside the Zsh one, then you can execute the commands mentioned above or your original test.

@toonvanacker
Copy link
Author

I'm running Bash, so that probably isn't the issue.

Sadly, neither of the above two suggestions worked out. If you have any further suggestions, I'm more than willing to try to help pinpoint the issue.

If you don't have the time, that's alright. I assume it works fine for most people, I'm probably hitting some strange edge case.

@mrsarm
Copy link
Owner

mrsarm commented Jun 19, 2020

Sorry, I tested in the past the plugin only with Java 9 (the minimal version required) and 11 (the latest LTS by the way) and it was working, now testing it with Java 12, 13 and 14 I realized it fails in the same way it's failing you: executing the Jshell and then immediately exiting the process, and it was reported also in #1 but i did not pay attention on that time because I was implementing a refactor.

So the good news is that at least we know why is failing: it does not work with Java 12+, and I will try to fix the problem next week, meanwhile you can try it with Java 11. If it is a problem to downgrade your Java version installed, I recommend you to setup SdkMan!, I use it and it's an amazing tool to setup different environments in the same computer and without breaking the system installation.

@mrsarm mrsarm added the bug Something isn't working label Jun 19, 2020
@toonvanacker
Copy link
Author

Thanks for the update!

@mrsarm
Copy link
Owner

mrsarm commented Jun 25, 2020

@toonvanacker I made some tests yesterday and I couldn't figure out why the API the plugin uses to launch the JShell stops to work correctly since Java 12 when launched with Gradle. I think is related with the really bad way Gradle manages the standard input and output streams, that also cause the autocomplete and history futures built in the JShell to not work, I'll add in the README a warning about the incompatibility, but at least for now I don't have more time to investigate the issue 🤷‍♂️

@toonvanacker
Copy link
Author

I appreciate the effort, in any case. Hopefully one day it'll be fixed.

@mrsarm
Copy link
Owner

mrsarm commented Jun 25, 2020

BTW, what it works with Java 12+ is to run JShell script in a .jsh file, quote from the README:

If the plugin founds at the root of the project a JShell Script named startup.jsh, it will append to the JShell session the argument --startup startup.jsh, executing at the beginning all the instruction in the script, so you can add there all the imports, object definitions or any Java instruction that you want to execute at the begging of the session. You can override the startup script path with the project property jshell.startup in the gradle.properties file, or set the same property in the command line arguments, like:

$ gradle --console plain jshell -Pjshell.startup=/path/to/run.jsh

If you have a startup.jsh script at the root of the project but at some point you don't want to execute it nor any other startup script, just pass the jshell.startup property with an empty value: gradle --console plain jshell -Pjshell.startup=.

But once executed the instructions in the .jsh file, the session is also exited, but at least it allows you to run a small script without run the all application.

@marcin-chwedczuk
Copy link

marcin-chwedczuk commented Jul 12, 2020

I had the same problem with JDK14.

./gradlew  --console plain jshell                                      

> Task :jshellSetup
:jshell task :classes not found, be sure to compile the project first

> Task :jshell
|  Welcome to JShell -- Version 14.0.1
|  For an introduction type: /help intro

BUILD SUCCESSFUL in 984ms
2 actionable tasks: 2 executed

jshell just stops, no info WTF went wrong. When I specify a start script, it looks like none of my dependencies was loaded (the script errors on the first import statement).

@mrsarm mrsarm added the wontfix This will not be worked on label Jul 16, 2021
@mrsarm
Copy link
Owner

mrsarm commented Jul 16, 2021

Closing this because won't be fixed, and don't have any effect in the final outcome, the problem of JShell being exited earlier is not related with this, that error was fixed and the patch released yesterday: check out 1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants