-
Notifications
You must be signed in to change notification settings - Fork 40.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maven compiler plugin configuration should not include source and target as maven.compiler.release is already set #34761
Maven compiler plugin configuration should not include source and target as maven.compiler.release is already set #34761
Conversation
Indeed a073ef8 was not enough, Note that with javac --release option e.g. for JDK 19
I wonder it is possible to target Spring and Spring Boot to JDK 8 via this cross compilation? But for sure simpler project can use this to target jdk 8 or jdk 11 |
And I am sure this switch to --release option should be refrected somewhere in docs
or configuration section for maven-compiler-plugin I wonder what exact error maven or javac give when there is mix of --target and --release options? |
There is also an explicit reference for JDK9+ https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html |
Maven docs however do not make it clear that there is big difference between https://stackoverflow.com/questions/43102787/what-is-the-release-flag-in-the-java-9-compiler |
I have tried Spring Boot 3.0 with added section like <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>17</release>
</configuration>
</plugin> In this case maven-compiler-plugin 3.11.0 just ignores source and target
But when
That is telling about --source option not about --release; <source>17</source>
<target>17</target>
<release>8</release> will not make difference. https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html page is also misleading In short this PR will make But whatever wording of error messages, the Stackoverflow.com solution will be: for Spring Boot 3.1+ use <properties>
<java.version>17</java.version> |
@arend-von-reinersdorff thank you for making your first contribution to Spring Boot. |
Follow-up on #34365.
When the compiler's release argument is set, arguments source and target are not used. No need to keep them around.
See https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-release
Maven actually allows setting both. But using both directly with javac would result in an error.