Marcono1234 created SUREFIRE-1976:
-------------------------------------

             Summary: Surefire fails when jdkToolchain is specified but no 
toolchains are configured
                 Key: SUREFIRE-1976
                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1976
             Project: Maven Surefire
          Issue Type: Bug
    Affects Versions: 3.0.0-M5
            Reporter: Marcono1234


Surefire fails when using {{jdkToolchain}} but no toolchains are defined (no 
{{.m2/toolchains.xml}} file exists).
This differs from the behavior of other plugins, such as maven-compiler-plugin 
or maven-javadoc-plugin which fall back to using 
{{getToolchainFromBuildContext}}:
- 
[maven-compiler-plugin|https://github.com/apache/maven-compiler-plugin/blob/6335382f97aad2e69b9f9a0a4af3cf801cd29273/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java#L1467-L1470]
- 
[maven-javadoc-plugin|https://github.com/apache/maven-javadoc-plugin/blob/651b98e6951ee2e3d8fefa1bcb3629f1dae763be/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java#L2974-L2977]

(Though they do not verify that it matches the {{jdkToolchain}} constraints, 
which is also a bit questionable because you might then run into other issues 
during plugin execution because that toolchain is incompatible. And most likely 
there are other plugins out there which behave like Surefire regarding 
{{jdkToolchain}} support.)

This behavior is quite useful because it allows users without 
{{toolchains.xml}} to still build the project. My usecase for toolchains is 
currently to make sure that the JDK is >= JDK 11, which is most likely the case 
for most users. Though arguably the Maven Enforcer Plugin could be used for 
this (but then it might be a bit cumbersome for users which do actually have a 
{{toolchains.xml}} set up).



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to