mthmulders commented on code in PR #14:
URL:
https://github.com/apache/maven-toolchains-plugin/pull/14#discussion_r1513962159
##########
src/main/java/org/apache/maven/plugins/toolchain/jdk/ToolchainDiscoverer.java:
##########
@@ -411,10 +411,12 @@ private Set<Path> findJdks() {
installedDirs.add(Paths.get(userHome,
"Library/Java/JavaVirtualMachines"));
} else if (win) {
installedDirs.add(Paths.get("C:\\Program Files\\Java\\"));
- Path scoop = Paths.get(userHome, "scoop/apps");
+ Path scoop = Paths.get(userHome, "scoop", "apps");
if (Files.isDirectory(scoop)) {
try (Stream<Path> stream = Files.list(scoop)) {
- stream.forEach(dirsToTest::add);
+ // Scoop can install multiple versions of a Java
distribution, we only take the one that is
+ // currently selected.
+ stream.map(path -> Paths.get(path.toString(),
"current")).forEach(dirsToTest::add);
Review Comment:
Please see [this
gist](https://gist.github.com/mthmulders/3c13223127254ace12190b9927940ee3). To
create it, I've added some debug logging to print which directories indeed
contain `bin/javac` or `bin/javac.exe`. I did that after the `filter` in line
444 to not print all packages I have installed that aren't a Java runtime.
If we only look at `Paths.get(userHome, "scoop", "apps");`, we will miss all
installed runtimes - only the "current" one (which `JAVA_HOME` points to) will
be detected. This is
[file-inspect-scoop-apps-packagename-txt](https://gist.github.com/mthmulders/3c13223127254ace12190b9927940ee3#file-inspect-scoop-apps-packagename-txt).
Looking at the `current` directory under each installed package will make
the code detect the current version of each installed Java runtime. So that is
a lot more, but still not all. This is
[inspect-scoop-apps-packagename-current-txt](https://gist.github.com/mthmulders/3c13223127254ace12190b9927940ee3#file-inspect-scoop-apps-packagename-current-txt).
To find all of them (as you wrote), we'd need to look at each subdirectory
of an installed package. It will incur a lot of disk scanning, because it will
inspect each installed version of each Scoop package, but it will even detect
multiple versions of the same Java runtime (see openjdk21, microsoft17-jdk).
This is
[inspect-scoop-apps-packagename-all-subdirs-txt](https://gist.github.com/mthmulders/3c13223127254ace12190b9927940ee3#file-inspect-scoop-apps-packagename-all-subdirs-txt).
It will also report the *current* version of that package (so that's a
duplicate), but we could filter those out I believe.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]