apache / apache/maven-toolchains-plugin
JDK discovery mechanism now working as expected
- Dominant language
- Java
- Stars
- 27
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
### Affected version
3.2.0
### Bug description
Executing `mvn org.apache.maven.plugins:maven-toolchains-plugin:3.2.0:display-discovered-jdk-toolchains` works, and returns all JDKs installed on my machine, but I don't know how to cinfigure Maven to use Java 8 for project runtime.
This auto discovery mechanism should work without `~/.m2/toolchains.xml` file per [documentation](https://maven.apache.org/plugins/maven-toolchains-plugin/toolchains/jdk-discovery.html).
My goal is to run project with Java 8.
My `pom.xml`:
```xml
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.7.18
com.username.mock
webserver
0.0.1-SNAPSHOT
webserver
Demo project for Spring Boot
1.8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-toolchains-plugin
3.2.0
select-jdk-toolchain
true
8
```
Error I get with `mvn spring-boot:run`:
```
[INFO] Found 5 possible jdks: [/usr/lib/jvm/java-21-openjdk, /usr/lib/jvm/java-11-openjdk, /usr/lib/jvm/java-24-openjdk, /usr/lib/jvm/java-17-openjdk, /usr/lib/jvm/java-8-openjdk]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.884 s
[INFO] Finished at: 2025-06-18T13:41:51+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:3.2.0:select-jdk-toolchain (default) on project webserver: Cannot find matching toolchain definitions for the following toolchain types:{runtime.version=8}
[ERROR] Define the required toolchains in your ~/.m2/toolchains.xml file.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.