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

Document conditional setting of the --release property

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.11.0
    • 3.12.0
    • None

    Description

      Apache Commons Parent 57 RC1 (https://lists.apache.org/thread/rwgf9c7dgl2bymq3jg6ckxs6gk9pz4mg) attempts to use the javac release flag only on Java 9 and above with 

      <maven.compiler.release>8</maven.compiler.release>
      

      and

          <profile>
            <id>jdk9-compiler</id>
            <activation>
              <jdk>[9</jdk>
            </activation>
            <build>
          	<pluginManagement>
         	      <plugins>
                  <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                      <release>${maven.compiler.release}</release>
                    </configuration>
                  </plugin>
                </plugins>
              </pluginManagement>
            </build>
          </profile>
      

      This fails miserably:

      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time:  5.402 s
      [INFO] Finished at: 2023-04-23T09:23:21-04:00
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project commons-lang3: Fatal error compiling: invalid flag: --release -> [Help 1]
      [ERROR]
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR]
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
      

      IMO, setting a property "maven.compiler.release" should not be used on compilers that do not support the flag.

      Attachments

        Issue Links

          Activity

            People

              michael-o Michael Osipov
              ggregory Gary D. Gregory
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: