Skip to content

Commit 9ecd403

Browse files
Copilotbytemain
andcommitted
Add JavaFX bundled version support with -fx suffix
Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
1 parent 755feb0 commit 9ecd403

File tree

5 files changed

+95
-8
lines changed

5 files changed

+95
-8
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-fx-distribution` (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)
25+
vfox install java@21.0.5-fx-zulu # Zulu with JavaFX
26+
vfox install java@21.0.5-fx-librca # 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 in the version list and marked with "JavaFX" in the notes. To install a JavaFX bundled version, add `-fx` to the version string:
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-fx-zulu # JavaFX
45+
# 17.0.13-zulu
46+
# 17.0.13-fx-zulu # JavaFX
47+
48+
# Install JavaFX bundled version
49+
vfox install java@21.0.5-fx-zulu
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-fx-distribution` (带 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-fx-zulu # 带 JavaFX 的 Zulu
23+
vfox install java@21.0.5-fx-librca # 带 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-fx-zulu # JavaFX
41+
# 17.0.13-zulu
42+
# 17.0.13-fx-zulu # JavaFX
43+
44+
# 安装带 JavaFX 的版本
45+
vfox install java@21.0.5-fx-zulu
46+
```
47+
2748
# 支持的JDK发行版
2849

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

hooks/available.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,35 @@ function PLUGIN:Available(ctx)
2929
for _, jdk in ipairs(jdks) do
3030
local v = jdk.java_version
3131
local short = jdk.short
32+
33+
-- Add -fx suffix for JavaFX bundled versions
34+
local fx_suffix = ""
35+
if jdk.javafx_bundled == true then
36+
fx_suffix = "-fx"
37+
end
38+
3239
if query == "all" then
33-
v = v .. "-" .. short
40+
v = v .. fx_suffix .. "-" .. short
3441
elseif query == "open" then
35-
v = v
42+
v = v .. fx_suffix
3643
else
3744
local distribution = distribution_version_parser.parse_distribution(query)
3845
if not distribution then
3946
error("Unsupported distribution: " .. query)
4047
end
41-
v = v .. "-" .. distribution.short_name
48+
v = v .. fx_suffix .. "-" .. distribution.short_name
4249
end
4350

4451
if not seen[v] then
4552
seen[v] = true
4653
-- check if version exists
54+
local note = jdk.term_of_support == "lts" and "LTS" or ""
55+
if jdk.javafx_bundled == true then
56+
note = note == "" and "JavaFX" or note .. ", JavaFX"
57+
end
4758
table.insert(result, {
4859
version = v,
49-
note = jdk.term_of_support == "lts" and "LTS" or ""
60+
note = note
5061
})
5162
end
5263

hooks/pre_install.lua

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,35 @@ 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
44+
local fx_suffix = ""
45+
if jdk.javafx_bundled == true then
46+
fx_suffix = "-fx"
47+
end
48+
local finalV = distribution_version.distribution.short_name == "open" and jdk.java_version .. fx_suffix or jdk.java_version .. fx_suffix .. "-" .. distribution_version.distribution.short_name
2849
return {
2950
-- [info.checksum_type] = checksum,
3051
url = info.direct_download_uri,

lib/distribution_version.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ 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 for "fx" in any part and remove it, setting javafx_bundled flag
65+
local filtered_parts = {}
66+
for _, part in ipairs(version_parts) do
67+
if part == "fx" then
68+
javafx_bundled = true
69+
else
70+
table.insert(filtered_parts, part)
71+
end
72+
end
73+
version_parts = filtered_parts
6274

6375
if not version_parts[2] then
6476
-- no parts, check if we got a distribution name without version
@@ -90,6 +102,7 @@ function distribution_version.parse_version (arg)
90102
return {
91103
version = version,
92104
distribution = distribution,
105+
javafx_bundled = javafx_bundled,
93106
}
94107
end
95108

0 commit comments

Comments
 (0)