You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 85e4555
Browse filesBrowse the repository at this point in the historyBrowse files
feat: add Detect hook, so that vfox link --detect java finds existing JDKs
Implements #127, part of version-fox/vfox#737.
Scans Gradle's jdks folder, IntelliJ IDEA's folder, system directories
(/usr/lib/jvm, Program Files), version managers (SDKMAN, asdf, mise,
jabba), Homebrew kegs (incl. Linuxbrew), Scoop apps, the CI runner tool
cache and JAVA_HOME. winget/Chocolatey/vendor installers land in Program
Files and are covered by the same roots; nvm manages Node.js only.
Reads each candidate's release file and names the version like install
does: runtime version (SEMANTIC_VERSION or leading release+build),
GraalVM's own version for that family, then -short name from IMPLEMENTOR
and -fx for JavaFX, no suffix for OpenJDK.
Includes offline tests in the vfox.test style (test.load with os/arch/env,
faked directory listings and release files): naming, bundles, kegs, deep
scans, duplicates and .vfox filtering. Bumps the Test Plugin workflow to
vfox 1.1.0, which brings the Detect hook.
`vfox --debug <command>` shows what vfox does with a hook, which is how to find an error it swallows.
105
108
109
+
## Detecting installed JDKs
110
+
111
+
`hooks/detect.lua` implements `Detect` for `vfox link --detect java`: it scans Gradle's provisioning folder (`$GRADLE_USER_HOME/jdks`), IntelliJ IDEA's folder (`~/.jdks`, `~/Library/Java/JavaVirtualMachines` on macOS), the system directories (`/usr/lib/jvm`, `/Library/Java/JavaVirtualMachines` on macOS, `C:\Program Files\*` on Windows), the version managers SDKMAN, asdf, mise and jabba, Homebrew kegs (`/opt/homebrew/opt`, `/usr/local/opt`, Linuxbrew), Scoop apps (`~/scoop/apps`), the CI runner tool cache and `JAVA_HOME`, and reports every JDK home it finds as `{ version, path, note }`. winget, Chocolatey and the vendor installers all land in `Program Files`, so the same Windows roots cover them; nvm manages Node.js only, so there is nothing Java-related to find in it.
112
+
113
+
`lib/detect_jdk.lua` reads each candidate's `release` file. The version is the runtime version (`SEMANTIC_VERSION`, else the leading `release+build` of `JAVA_RUNTIME_VERSION`), GraalVM's own version (`GRAALVM_VERSION`) for that family, then `-<short name>` from `IMPLEMENTOR` and `-fx` where `MODULES` mentions JavaFX, with no suffix for OpenJDK. System OpenJDKs (Ubuntu, Debian, `N/A`) map to no suffix; Oracle Corporation without `oracle` in the path stays OpenJDK, otherwise it is `oracle`. Mandrel's release file is the Temurin JDK it was built from, with no Mandrel version of its own, so it reports as Temurin (`tem`), and Liberica NIK without its own `GRAALVM_VERSION` reports as Liberica (`librca`); both stay usable JDKs under those names. Unknown vendors report with no suffix instead of a made-up one.
114
+
115
+
`tests/detect_test.lua` (plus `detect_env_test.lua`, `detect_darwin_test.lua` and `detect_windows_test.lua` for the environment, macOS and Windows roots) takes the platform and the environment through `test.load` (`os`, `arch`, `env`), fakes the directory listings and `release` files (`io.popen`, `io.open`) instead of touching real JDKs, and covers the naming, the macOS bundles and Homebrew kegs (`Contents/Home`, `libexec/openjdk.jdk/Contents/Home`), asdf/mise/jabba/Linuxbrew homes, Scoop's nested apps and mise on Windows, duplicate versions (the first path wins) and the `.vfox`-managed homes that must never be reported.
116
+
106
117
## Adding a distribution
107
118
108
119
1. Find its id in Foojay ([foojay.md](foojay.md)), and check that it has packages for the platforms you care about.
0 commit comments