maven-toolchains-plugin icon indicating copy to clipboard operation
maven-toolchains-plugin copied to clipboard

Include additional scan locations for auto discovery

Open Okeanos opened this issue 5 months ago • 0 comments

New feature, improvement proposal

Currently the following locations are scanned for auto-discovery as described in the ToolchainDiscoverer:

Generically

  • $HOME/.jdks
  • $HOME/.m2/jdks
  • $HOME/.sdkman/candidates/java
  • $HOME/.gradle/jdks
  • $HOME/.jenv/versions
  • $HOME/.jbang/cache/jdks
  • $HOME/.asdf/installs
  • $HOME/.jabba/jdk

macOS

  • /Library/Java/JavaVirtualMachines
  • $HOME/Library/Java/JavaVirtualMachines

Linux

  • /usr/jdk
  • /usr/java
  • /opt/java
  • /usr/lib/jvm

Windows

  • C:\Program Files\Java
  • $HOME\scoop\apps

I would like to see the following locations added for auto-discovery:

Generically

  • $HOME/.local/share/mise/installs/java to support mise (an alternative to asdf)

Beyond that many of the generic tools (ASDF ASDF_DATA_DIR, mise MISE_DATA_DIR, Jabba JABBA_HOME, SDKMAN SDKMAN_CANDIDATES_DIR, jenv JENV_ROOT) can be configured via environment variables that change the location of where tools are installed.

It would probably be a good addition to consider these variables when scanning for Java locations.

macOS

  • $HOME/hostedtoolcache (/Users/runner/hostedtoolcache) to support arbitrary JDKs installed in GitHub Workflows using actions/setup-java

Linux

Windows

  • C:\hostedtoolcache\windows to support arbitrary JDKs installed in GitHub Workflows using actions/setup-java

For Windows (similar to what Gradle does for its Toolchain discovery) it would potentially be interesting to check the registry as well.


Why explicitly add support for GitHub when the setup-java action already creates a static toolchains.xml? Because they behave differently than the auto-discovered ones, particularly for older JDKs (up until the version name change from 1.x to x), concerning version names that can be selected. This makes usage cumbersome, if people locally have not setup toolchains as well.

Okeanos avatar Aug 14 '25 11:08 Okeanos