Skip to content

Commit 4d92c3d

Browse files
committed
feat: add build workspace command
1 parent 5b07857 commit 4d92c3d

4 files changed

Lines changed: 54 additions & 4 deletions

File tree

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Yep! That's all :)
8383

8484
<summary>:small_orange_diamond:details</summary>
8585

86+
### Build
87+
88+
- `JavaBuildWorkspace` - Runs a full workspace build
89+
8690
### Runner
8791

8892
- `JavaRunnerRunMain` - Runs the application or selected main class (if there
@@ -125,6 +129,14 @@ Yep! That's all :)
125129

126130
<summary>:small_orange_diamond:details</summary>
127131

132+
### Build
133+
134+
- `build.build_workspace` - Runs a full workspace build
135+
136+
```lua
137+
require('java').build.build_workspace()
138+
```
139+
128140
### Runner
129141

130142
- `built_in.run_app` - Runs the application or selected main class (if there
@@ -397,7 +409,14 @@ For instance, to run the current test,
397409

398410
## :bookmark_tabs: Projects Acknowledgement
399411

400-
[nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls) is a plugin that follows
401-
"Keep it simple, stupid!" approach. If you love customizing things by yourself,
402-
then give nvim-jdtls a try. I may or may not have copied some code :wink:
403-
Beauty of Open source!
412+
- [spring-boot.nvim](https://github.com/JavaHello/spring-boot.nvim) is the one
413+
that starts sts4 & do other necessary `jdtls` `sts4` sync command registration
414+
in `nvim-java`.
415+
416+
- [nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls) is a plugin that follows
417+
"Keep it simple, stupid!" approach. If you love customizing things by yourself,
418+
then give nvim-jdtls a try.
419+
420+
> [!WARNING]
421+
> You cannot use `nvim-java` alongside `nvim-jdtls`. So remove `nvim-jdtls`
422+
> before installing this

lua/java.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ local dap = require('java.api.dap')
88
local runner = require('java.api.runner')
99
local profile_ui = require('java.ui.profile')
1010
local refactor = require('java.api.refactor')
11+
local build_api = require('java.api.build')
1112

1213
local global_config = require('java.config')
1314

@@ -32,6 +33,12 @@ function M.setup(custom_config)
3233
end
3334
end
3435

36+
----------------------------------------------------------------------
37+
-- Experimental APIs --
38+
----------------------------------------------------------------------
39+
M.build = {}
40+
M.build.build_workspace = build_api.full_build_workspace
41+
3542
----------------------------------------------------------------------
3643
-- DAP APIs --
3744
----------------------------------------------------------------------

lua/java/api/build.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
local async = require('java-core.utils.async').sync
2+
local get_error_handler = require('java.handlers.error')
3+
4+
local M = {}
5+
6+
function M.full_build_workspace()
7+
return async(function()
8+
local JavaCoreJdtlsClient = require('java-core.ls.clients.jdtls-client')
9+
local jdtls = require('java.utils.jdtls')
10+
local buf_util = require('java.utils.buffer')
11+
local notify = require('java-core.utils.notify')
12+
13+
JavaCoreJdtlsClient:new(jdtls())
14+
:java_build_workspace(true, buf_util.get_curr_buf())
15+
16+
notify.info('Workspace build successful!')
17+
end)
18+
.catch(get_error_handler('Workspace build failed'))
19+
.run()
20+
end
21+
22+
return M

plugin/java.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ local function c(cmd, callback, opts)
55
end
66

77
local cmd_map = {
8+
JavaBuildWorkspace = { java.build.build_workspace },
9+
810
JavaDapConfig = { java.dap.config_dap },
911

1012
JavaTestRunCurrentClass = { java.test.run_current_class },

0 commit comments

Comments
 (0)