-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
feature: separate API to run & debug applications #4
Comments
At the moment I'm not sure how to execute main methods in run mode. I have started a discussion in nvim-dap to figure this out |
Hi there! What do you think about getting these data from jdtlsclient:
and setting up a command from these? I have tested this approach with both Maven and Gradle projects, and it works. |
@atm1020 you mean manually running the command through |
@s1n7ax I mean creating a command like this: |
To test out this idea, I have created this function ( in the nvim-core-java project.): --- @param callback fun(cmd: string[])
function M:run_app(callback)
local resolved_main_class_records = self.client:resolve_main_class()
-- multiple main classes ?
local main_class = resolved_main_class_records[1].mainClass
local project_name = resolved_main_class_records[1].projectName
local file_path = resolved_main_class_records[1].filePath
log.debug('main class: ' .. main_class .. " project name: " .. project_name .. " filePath: " .. file_path )
local resolved_java_executable = self.client:resolve_java_executable(
main_class,
project_name
)
log.debug('java exec: ' .. resolved_java_executable)
self.client:build_workspace(project_name,project_name, file_path, true)
local classpath = table.concat(self.client:resolve_classpath(main_class,project_name)[2], ':')
log.debug('classpath: ' .. classpath)
local cmd = {
resolved_java_executable,
'-cp',
classpath,
main_class
}
callback(cmd)
end with a callback function, the users can choose where they want to run a command. For example, in my case, i like to use toogleterm. |
@atm1020 Cool. I guess we could introduce this initially and intellij like features later on. Things like logs from previous executions, stop and re-run etc... |
@s1n7ax Yes, I agree. May I try implementing this feature? |
@atm1020 Sure. Ask me if you got any questions |
@s1n7ax I think about two ways to do this:
(I think the first option is a better way to do this) |
@atm1020 client classes contains the commands defined by each component (naming could have been better)
So, moving them into jdtls-client is not suitable. It's likely that java-debug-client & java-test-client will be moved to respective projects in the future. Can't think of a place to define it but either nvim-java-core/lua/api or nvim-java-dap/lua/api/runner would be fine i guess |
@s1n7ax I didn't realize that, my bad. Thank you for the help. I will implement this in the nvim-java-core project. |
@s1n7ax I found a small bug that needs to be fixed for this feature: The
Should I solve it within this feature or create a separate PR? |
No just go ahead and change in the same PR. Add two commits |
@atm1020 Hi. I'm sorry. I completely missed the fact that we already do something like this. Using enrich config you can get the classpath for a given mainClass in a project. So the changes you have made to nvim-java-core can be avoided. In the nvim-java project you can define the Lua API. When there are multiple main classes, you can use |
@s1n7ax No problem! I have closed the PR, and i will try to implement that in the nvim-java project. |
* feat: add openjdk-17 * fix: openjdk category is not valid * fix: invalid source package id
Parent issue: #13
The text was updated successfully, but these errors were encountered: