Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ vfox install java@x.y.z # Use openjdk as default distribution.
vfox install java@x.y.z-graal # Use graalvm as distribution.

# view all available versions
vfox search java all # view all java sdks
vfox search java # view all for openjdk
vfox search java graal # view all for graalvm
```
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ vfox install java@x.y.z # 默认使用openjdk
vfox install java@x.y.z-graal # 使用graalvm

# 查看所有可用版本
vfox search java all # 查看所有sdk版本
vfox search java # 查看所有openjdk版本
vfox search java graal # 查看所有graalvm版本
```
Expand Down
41 changes: 27 additions & 14 deletions hooks/available.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,39 @@ local shortname = require("shortname")
--- @param ctx table Empty table used as context, for future extension
--- @return table Descriptions of available versions and accompanying tool descriptions
function PLUGIN:Available(ctx)
local distribution = ctx.args[1] or "open"
if not shortname[distribution] then
error("Unsupport distribution: " .. distribution)
local distribution = ctx.args[1]
local jdks = {}

if distribution and distribution == "all" then
for short, dist in pairs(shortname) do
local tempJdks = foojay.fetchtJdkList(dist, "")
for _, jdk in ipairs(tempJdks) do
jdk.short = short
table.insert(jdks, jdk)
end
end
else
jdks = foojay.fetchtJdkList(shortname[distribution] or error("Unsupported distribution: " .. distribution), "")
end
local jdks = foojay.fetchtJdkList(shortname[distribution], "")

local result = {}
local seen = {}
for _, jdk in ipairs(jdks) do
local v = jdk.java_version
if distribution ~= "open" then
v = v .. "-" .. distribution
local short = jdk.short
if short and short ~= "open" then
v = v .. "-" .. short
end
local note = ""
if jdk.term_of_support == "lts" then
note = "LTS"

if not seen[v] then
seen[v] = true
-- check if version exists
table.insert(result, {
version = v,
note = jdk.term_of_support == "lts" and "LTS" or ""
})
end
table.insert(result, {
version = v,
note = note,
})

end
return result
end
end
2 changes: 1 addition & 1 deletion metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PLUGIN = {}
--- Plugin name
PLUGIN.name = "java"
--- Plugin version
PLUGIN.version = "0.1.1"
PLUGIN.version = "0.1.2"
--- Plugin homepage
PLUGIN.homepage = "https://github.com/version-fox/vfox-java"
--- Plugin license, please choose a correct license according to your needs.
Expand Down