Skip to content

Commit 6d51d65

Browse files
Copilotbytemain
andauthored
Add JavaFX bundled version support with -fx suffix (#48)
* Initial plan * Add JavaFX bundled version support with -fx suffix Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> * Address code review feedback: improve readability Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> * Move -fx suffix after distribution name (e.g., zulu-fx instead of fx-zulu) Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
1 parent 7be37af commit 6d51d65

File tree

5 files changed

+101
-16
lines changed

5 files changed

+101
-16
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Support for multiple JDK distributions, such as: Oracle, Graalvm, Eclipse & more
99

1010
# Usage
1111

12-
**Parameter Format**: `x.y.z-distribution`
12+
**Parameter Format**: `x.y.z-distribution` or `x.y.z-distribution-fx` (for JavaFX bundled versions)
1313

1414
```shell
1515
# add plugin for vfox
@@ -21,13 +21,34 @@ vfox install java@17.0.17-tem # Temurin
2121
vfox install java@17.0.17-zulu # Zulu
2222
vfox install java@17-graal # GraalVM (latest 17.x)
2323

24+
# install JavaFX bundled versions (use -fx suffix after distribution)
25+
vfox install java@21.0.5-zulu-fx # Zulu with JavaFX
26+
vfox install java@21.0.5-librca-fx # Liberica with JavaFX
27+
2428
# view all available versions
2529
vfox search java # view all openjdk versions
2630
vfox search java tem # view all temurin versions
2731
vfox search java zulu # view all zulu versions
2832
vfox search java graal # view all graalvm versions
2933
```
3034

35+
## JavaFX Support
36+
37+
Some distributions provide JDK versions bundled with JavaFX. These versions are displayed with the `-fx` suffix after the distribution name in the version list and marked with "JavaFX" in the notes. To install a JavaFX bundled version, add `-fx` after the distribution name:
38+
39+
```shell
40+
# List versions (JavaFX versions will show -fx suffix)
41+
vfox search java zulu
42+
# Example output:
43+
# 21.0.5-zulu
44+
# 21.0.5-zulu-fx # JavaFX
45+
# 17.0.13-zulu
46+
# 17.0.13-zulu-fx # JavaFX
47+
48+
# Install JavaFX bundled version
49+
vfox install java@21.0.5-zulu-fx
50+
```
51+
3152
# Supported JDK Distributions
3253

3354
> Thanks [SDKMAN](https://sdkman.io/jdks)!

README_CN.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# 使用
1010

11-
**参数格式**: x.y.z-distribution
11+
**参数格式**: `x.y.z-distribution``x.y.z-distribution-fx` (带 JavaFX 的版本)
1212

1313
```shell
1414
# 添加插件
@@ -18,12 +18,33 @@ vfox add java
1818
vfox install java@x.y.z # 默认使用openjdk
1919
vfox install java@x.y.z-graal # 使用graalvm
2020

21+
# 安装带 JavaFX 的版本 (在发行版名称后添加 -fx 后缀)
22+
vfox install java@21.0.5-zulu-fx # 带 JavaFX 的 Zulu
23+
vfox install java@21.0.5-librca-fx # 带 JavaFX 的 Liberica
24+
2125
# 查看所有可用版本
2226
vfox search java all # 查看所有sdk版本
2327
vfox search java # 查看所有openjdk版本
2428
vfox search java graal # 查看所有graalvm版本
2529
```
2630

31+
## JavaFX 支持
32+
33+
部分发行版提供了捆绑 JavaFX 的 JDK 版本。这些版本在版本列表中会在发行版名称后显示 `-fx` 后缀,并在备注中标注 "JavaFX"。安装带 JavaFX 的版本时,需要在发行版名称后添加 `-fx`
34+
35+
```shell
36+
# 查看版本列表 (带 JavaFX 的版本会显示 -fx 后缀)
37+
vfox search java zulu
38+
# 示例输出:
39+
# 21.0.5-zulu
40+
# 21.0.5-zulu-fx # JavaFX
41+
# 17.0.13-zulu
42+
# 17.0.13-zulu-fx # JavaFX
43+
44+
# 安装带 JavaFX 的版本
45+
vfox install java@21.0.5-zulu-fx
46+
```
47+
2748
# 支持的JDK发行版
2849

2950
> Thanks [SDKMAN](https://sdkman.io/jdks)!

hooks/available.lua

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ local distribution_version_parser = require("distribution_version")
77
function PLUGIN:Available(ctx)
88
local query = ctx.args[1] or "open"
99
local jdks = {}
10+
local distribution = nil
1011

1112
if query == "all" then
12-
for _, distribution in ipairs(distribution_version_parser.distributions) do
13-
local tempJdks = foojay.fetchtJdkList(distribution.name, "")
13+
for _, dist in ipairs(distribution_version_parser.distributions) do
14+
local tempJdks = foojay.fetchtJdkList(dist.name, "")
1415
for _, jdk in ipairs(tempJdks) do
15-
jdk.short = distribution.short_name
16+
jdk.short = dist.short_name
1617
table.insert(jdks, jdk)
1718
end
1819
end
1920
else
20-
local distribution = distribution_version_parser.parse_distribution(query)
21+
distribution = distribution_version_parser.parse_distribution(query)
2122
if not distribution then
2223
error("Unsupported distribution: " .. query)
2324
end
@@ -29,24 +30,31 @@ function PLUGIN:Available(ctx)
2930
for _, jdk in ipairs(jdks) do
3031
local v = jdk.java_version
3132
local short = jdk.short
33+
34+
-- Add -fx suffix for JavaFX bundled versions (after distribution name)
35+
local fx_suffix = ""
36+
if jdk.javafx_bundled == true then
37+
fx_suffix = "-fx"
38+
end
39+
3240
if query == "all" then
33-
v = v .. "-" .. short
41+
v = v .. "-" .. short .. fx_suffix
3442
elseif query == "open" then
35-
v = v
43+
v = v .. fx_suffix
3644
else
37-
local distribution = distribution_version_parser.parse_distribution(query)
38-
if not distribution then
39-
error("Unsupported distribution: " .. query)
40-
end
41-
v = v .. "-" .. distribution.short_name
45+
v = v .. "-" .. distribution.short_name .. fx_suffix
4246
end
4347

4448
if not seen[v] then
4549
seen[v] = true
4650
-- check if version exists
51+
local note = jdk.term_of_support == "lts" and "LTS" or ""
52+
if jdk.javafx_bundled == true then
53+
note = note == "" and "JavaFX" or note .. ", JavaFX"
54+
end
4755
table.insert(result, {
4856
version = v,
49-
note = jdk.term_of_support == "lts" and "LTS" or ""
57+
note = note
5058
})
5159
end
5260

hooks/pre_install.lua

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,41 @@ function PLUGIN:PreInstall(ctx)
1717
if not jdks or #jdks == 0 then
1818
error("No JDK found for " .. ctx.version .. " on " .. RUNTIME.osType .. "/" .. RUNTIME.archType .. ". Please check available versions with 'vfox search java'")
1919
end
20-
local jdk = jdks[1]
20+
21+
-- Filter JDKs based on JavaFX requirement
22+
local filtered_jdks = {}
23+
for _, jdk in ipairs(jdks) do
24+
local jdk_has_fx = jdk.javafx_bundled == true
25+
if distribution_version.javafx_bundled == jdk_has_fx then
26+
table.insert(filtered_jdks, jdk)
27+
end
28+
end
29+
30+
if #filtered_jdks == 0 then
31+
local fx_msg = distribution_version.javafx_bundled and " with JavaFX" or " without JavaFX"
32+
error("No JDK found for " .. ctx.version .. fx_msg .. " on " .. RUNTIME.osType .. "/" .. RUNTIME.archType .. ". Please check available versions with 'vfox search java'")
33+
end
34+
35+
local jdk = filtered_jdks[1]
2136
local info = json.decode(httpGet(jdk.links.pkg_info_uri, "Failed to fetch jdk info")).result[1]
2237
-- TODO: checksum
2338
-- local checksum = info.checksum
2439
-- if checksum == "" and info.checksum_uri ~= "" then
2540
-- checksum = httpGet(info.checksum_uri, "Failed to fetch checksum")
2641
-- end
27-
local finalV = distribution_version.distribution.short_name == "open" and jdk.java_version or jdk.java_version .. "-" .. distribution_version.distribution.short_name
42+
43+
-- Build final version string with fx suffix if needed (after distribution name)
44+
local fx_suffix = ""
45+
if jdk.javafx_bundled == true then
46+
fx_suffix = "-fx"
47+
end
48+
49+
local finalV
50+
if distribution_version.distribution.short_name == "open" then
51+
finalV = jdk.java_version .. fx_suffix
52+
else
53+
finalV = jdk.java_version .. "-" .. distribution_version.distribution.short_name .. fx_suffix
54+
end
2855
return {
2956
-- [info.checksum_type] = checksum,
3057
url = info.direct_download_uri,

lib/distribution_version.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ function distribution_version.parse_version (arg)
5959
local version_parts = strings.split(arg, "-")
6060
local version
6161
local distribution
62+
local javafx_bundled = false
63+
64+
-- Check if the last part is "fx" and remove it, setting javafx_bundled flag
65+
if version_parts[#version_parts] == "fx" then
66+
javafx_bundled = true
67+
table.remove(version_parts)
68+
end
6269

6370
if not version_parts[2] then
6471
-- no parts, check if we got a distribution name without version
@@ -90,6 +97,7 @@ function distribution_version.parse_version (arg)
9097
return {
9198
version = version,
9299
distribution = distribution,
100+
javafx_bundled = javafx_bundled,
93101
}
94102
end
95103

0 commit comments

Comments
 (0)