gnodet commented on code in PR #14:
URL: 
https://github.com/apache/maven-toolchains-plugin/pull/14#discussion_r1513488162


##########
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:
   > I'll double-check again one of these days, but I'm pretty sure that 
`<userHome>\scoop\apps` is not enough. Scoop-installed Java runtimes reside 
under `<userHome>\scoop\apps\<packageName>\<version>`
   
   I think the code was already checking those.  `installedDirs` should contain 
all `<userHome>\scoop\apps\<packageName>` while `dirsToTest` should later 
contain all `<userHome>\scoop\apps\<packageName>\<version>`.
   
   >, with `<userHome>\scoop\apps\<packageName>\current` as a symlink to the 
currently active version of that package.
   
   That one will be ignored, as symlinks are always transformed to a canonical 
path.  That's the one stored in the toolchain.
   
   > Regardless of that, the question remains: given that `openjdk21` has three 
installed versions (21.0.0, 21.0.1 and 21.0.2), do we want all of them to be 
detected or only the current one?
   
   The code is currently written to get *all* JDK.  The notion of `current` is 
specific to a given installer and we not be the latest one.  We have heuristic 
to choose amongst multiple versions and the goal in the discovery phase is to 
escape from "just the one configured in the shell".  So I'd rather have them 
all listed here and choose during toolchain matching / selection.
   



-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to