[ https://issues.apache.org/jira/browse/MTOOLCHAINS-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17823805#comment-17823805 ]
ASF GitHub Bot commented on MTOOLCHAINS-49: ------------------------------------------- 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 may 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. > Automatic discovery of JDK toolchains > ------------------------------------- > > Key: MTOOLCHAINS-49 > URL: https://issues.apache.org/jira/browse/MTOOLCHAINS-49 > Project: Maven Toolchains Plugin > Issue Type: Improvement > Reporter: Guillaume Nodet > Assignee: Guillaume Nodet > Priority: Major > -- This message was sent by Atlassian Jira (v8.20.10#820010)