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

Jorge Solórzano commented on MCOMPILER-545:
-------------------------------------------

Not sure what are you expecting, could you please explain better what is the 
issue? Are you setting the target to 1.8, building with JDK 11 and expect that 
the major version is 55?

If I change the maven.compiler.target property to 1.8, to 11, to 17, etc, the 
major version match the expected output.
 * JDK 8 => major version: 52
 * JDK 11 => major version: 55
 * JDK 17 => major version: 61

> maven.compiler.target seem to be ignored
> ----------------------------------------
>
>                 Key: MCOMPILER-545
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-545
>             Project: Maven Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 3.11.0
>            Reporter: Mihai Nita
>            Priority: Major
>
> Create a very simple maven project:
> {code:java}
> mvn archetype:generate \
>   -DgroupId=com.mycompany.app \
>   -DartifactId=my-app \
>   -DarchetypeArtifactId=maven-archetype-quickstart \
>   -DarchetypeVersion=1.4 \
>   -DinteractiveMode=false{code}
> See the guide at "Maven in 5 Minutes"
> [https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html]
>  
> Change folder:
> {code:java}
> cd my-app {code}
> Edit the `pom.xml` and change the JDK version to 8 (the newly created project 
> uses 7):
> {code:java}
> <maven.compiler.source>1.8</maven.compiler.source>
> <maven.compiler.target>1.8</maven.compiler.target> {code}
> Compile:
> {code:java}
> mvn clean compile {code}
> Check the version of the class file generated:
> {code:java}
> javap -v target/classes/com/mycompany/app/App.class | grep "major 
> version"{code}
> If you compile with various jdk versions you will get different results: * 
> JDK 8 => major version: 52
>  * JDK 11 => major version: 55
>  * JDK 17 => major version: 61
> So this is not work as one would expect (and as documented).
> It looks like a bug in the {{{}maven-compiler-plugin{}}}.
>  
> The behavior is the same even if we update the plugin to latest version 
> (3.11.0).
> (the app generated by the archetype uses 3.8.0, so the bug is not new)
> Or if we use `8` for the version (instead of `1.8`).
> [https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html]
>  
> Changing the version *works* if specified in the plugin using 
> {{<configuration>}} in {{{}<plugin>{}}}.
> [https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html]
>  
> This show that {{maven.compiler.target}} does not work.
> I suspect (but didn't test) that is also true for {{maven.compiler.source}}
>  



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

Reply via email to