enc: simplify neotest adaptor for java

This commit is contained in:
Pojok Code 2024-11-14 06:48:20 +07:00
parent d186be6aec
commit e0a4367eb0

View file

@ -30,28 +30,15 @@ M = {
"andy-bell101/neotest-java", "andy-bell101/neotest-java",
}, },
config = function() config = function()
local project_type = "maven" -- local project_type = "maven"
local gradle_file = vim.fn.findfile("build.gradle", vim.fn.getcwd()) -- local gradle_file = vim.fn.findfile("build.gradle", vim.fn.getcwd())
if gradle_file then -- if gradle_file then
project_type = "gradle" -- project_type = "gradle"
end -- end
require("neotest").setup({ require("neotest").setup({
adapters = { adapters = {
require("neotest-java")({ require("neotest-java"),
-- function to determine which runner to use based on project path
determine_runner = function(project_root_path)
-- return should be "maven" or "gradle"
return project_type
end,
-- override the builtin runner discovery behaviour to always use given
-- tool. Default is "nil", so no override
force_runner = nil,
-- if the automatic runner discovery can't uniquely determine whether
-- to use Gradle or Maven, fallback to using this runner. Default is
-- "gradle or maven"
fallback_runner = project_type,
}),
}, },
}) })
end, end,