[ 
https://issues.apache.org/jira/browse/MCOMPILER-534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17718082#comment-17718082
 ] 

ASF GitHub Bot commented on MCOMPILER-534:
------------------------------------------

aherbert commented on code in PR #187:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/187#discussion_r1181267491


##########
src/site/apt/examples/set-compiler-release.apt.vm:
##########
@@ -80,3 +80,30 @@ Setting the <<<--release>>> of the Java Compiler
   since Java 9. As such, the release number does not start with 1.x anymore. 
Also note that the
   supported <<<release>>> targets include the release of the currently used 
JDK plus a limited number
   of previous releases.
+
+* Usage on JDK 8
+
+  The <<<--release>>> option is used to target an older Java release than the 
JDK used during the
+  build process. This flag is not supported using JDK 8. To enable a project 
that targets Java 8
+  to be built using JDK 8 or later requires the conditional usage of the 
<<<--release>>> option.

Review Comment:
   Change "it requires this flag" to "it requires this flag when using a JDK 
later than 8".
   
   If you use the flag with JDK 8 then the build breaks. This was the original 
source of [MCOMPILER-534]. You can only use the flag with JDK 9+:
   
   ```
   Target   Tool chain   --release flag    Result
   Java 8   JDK 8        Y                 build error
   Java 8   JDK 8        N                 OK
   Java 8   JDK 9        Y                 OK (compiler targets Java 8)
   Java 8   JDK 9        N                 compiler targets Java 9 API methods 
that supersede Java 8 methods
   ```
   
   If this is not the desired behaviour, i.e. the --release flag should be 
harmless if set on JDK 8, then something should be changed in the compiler 
plugin. If you should not use the flag when using JDK 8, then this is what I am 
trying to address with this documentation.
   





> Broken command line generated on Java 8 when maven.compiler.release is set
> --------------------------------------------------------------------------
>
>                 Key: MCOMPILER-534
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-534
>             Project: Maven Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 3.11.0
>         Environment: Apache Maven 3.9.1 
> (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
> Maven home: /usr/local/Cellar/maven/3.9.1/libexec
> Java version: 1.8.0_362, vendor: Homebrew, runtime: 
> /usr/local/Cellar/openjdk@8/1.8.0+362/libexec/openjdk.jdk/Contents/Home/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "mac os x", version: "13.3.1", arch: "x86_64", family: "mac"
> Darwin **** 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:17 PST 
> 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64
>            Reporter: Gary D. Gregory
>            Priority: Major
>
> 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 
> {code:xml}
> <maven.compiler.release>8</maven.compiler.release>
> {code}
> and
> {code:xml}
>     <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>
> {code}
> This fails miserably:
> {noformat}
> [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
> {noformat}
> IMO, setting a property "maven.compiler.release" should not be used on 
> compilers that do not support the flag.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to