|
1 | 1 | local mason = require('java-core.utils.mason') |
2 | | -local path = require('java-core.utils.path') |
3 | 2 | local file = require('java-core.utils.file') |
4 | 3 |
|
5 | 4 | local List = require('java-core.utils.list') |
6 | 5 |
|
7 | 6 | local M = {} |
8 | 7 |
|
9 | | -local plugin_to_jar_path_map = { |
10 | | - ['java-test'] = '*.jar', |
11 | | - ['java-debug-adapter'] = '*.jar', |
| 8 | +local plug_jar_map = { |
| 9 | + ['java-test'] = { |
| 10 | + 'junit-jupiter-api_*.jar', |
| 11 | + 'junit-jupiter-engine_*.jar', |
| 12 | + 'junit-jupiter-migrationsupport_*.jar', |
| 13 | + 'junit-jupiter-params_*.jar', |
| 14 | + 'junit-platform-commons_*.jar', |
| 15 | + 'junit-platform-engine_*.jar', |
| 16 | + 'junit-platform-launcher_*.jar', |
| 17 | + 'junit-platform-runner_*.jar', |
| 18 | + 'junit-platform-suite-api_*.jar', |
| 19 | + 'junit-platform-suite-commons_*.jar', |
| 20 | + 'junit-platform-suite-engine_*.jar', |
| 21 | + 'junit-vintage-engine_*.jar', |
| 22 | + 'org.apiguardian.api_*.jar', |
| 23 | + 'org.eclipse.jdt.junit4.runtime_*.jar', |
| 24 | + 'org.eclipse.jdt.junit5.runtime_*.jar', |
| 25 | + 'org.opentest4j_*.jar', |
| 26 | + 'com.microsoft.java.test.plugin-*.jar', |
| 27 | + }, |
| 28 | + ['java-debug-adapter'] = { '*.jar' }, |
12 | 29 | } |
13 | 30 |
|
14 | 31 | ---Returns a list of .jar file paths for given list of jdtls plugins |
15 | | ----@param plugins string[] |
| 32 | +---@param plugin_names string[] |
16 | 33 | ---@return string[] # list of .jar file paths |
17 | | -function M.get_plugin_paths(plugins) |
18 | | - local plugin_paths = List:new() |
19 | | - |
20 | | - for _, plugin in ipairs(plugins) do |
21 | | - local relative_path = plugin_to_jar_path_map[plugin] |
22 | | - local plugin_shared_path = mason.get_shared_path(plugin) |
23 | | - local full_path = path.join(plugin_shared_path, relative_path) |
24 | | - local resolved_paths = file.get_file_list(full_path) |
25 | | - |
26 | | - plugin_paths:push(resolved_paths) |
27 | | - end |
28 | | - |
29 | | - return plugin_paths:flatten() |
| 34 | +function M.get_plugin_paths(plugin_names) |
| 35 | + return List:new(plugin_names) |
| 36 | + :map(function(plugin_name) |
| 37 | + local root = mason.get_shared_path(plugin_name) |
| 38 | + return file.resolve_paths(root, plug_jar_map[plugin_name]) |
| 39 | + end) |
| 40 | + :flatten() |
30 | 41 | end |
31 | 42 |
|
32 | 43 | return M |
0 commit comments