Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

[MCOMPILER-533] Output an error when --release option is used together with --source or --target #391

@sos-jira-migration-bot

Description

@sos-jira-migration-bot

Arend von Reinersdorff opened MCOMPILER-533 and commented

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 spring-projects/spring-boot#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.


Affects: 3.11.0

Issue Links:

  • MCOMPILER-582 Automatic detection of release option for JDK < 9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions