Uploaded image for project: 'Maven Compiler Plugin'
  1. Maven Compiler Plugin
  2. MCOMPILER-533

Output an error when --release option is used together with --source or --target

    XMLWordPrintableJSON

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

          Activity

            People

              Unassigned Unassigned
              arendvr.com Arend v. Reinersdorff
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: