Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
3.11.0
-
None
-
None
Description
javac outputs an error when the --release option is used together with the --source or --target option. See https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-release
For example:
javac --release 17 --target 17 ...
Will fail with this error:
error: option --target cannot be used together with --release
This is nice because it informs the user of misconfiguration and enforces the use of only --release or only --source/--target.
Unfortunately, the error is lost when compiling with Maven. Maven uses the release option and silently ignores source and target. Users don't notice when they unnecessarily set both. See for example https://github.com/spring-projects/spring-boot/pull/34761
For example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>17</release>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
Compiles using the release option without any error or warning.
It would be nice to restore the error from javac in Maven, or output a similar one.
The problem I see is that Maven uses default values for source and target. When the user sets only the release option, no error or warning should be caused because of the default values for source and target.
Attachments
Issue Links
- is related to
-
MCOMPILER-582 Automatic detection of release option for JDK < 9
- Closed