Update maven project sets wrong jdk compliance if release tag in mavencompiler-plugin is used
Closed this issue · 4 comments
Given the following pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>examplegroup</groupId>
<artifactId>exampleartifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<profiles>
<profile>
<id>java-9-plus</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>8</release>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
should result in setting the Eclipse project settings for the JDK compliance to Java 1.8, but sets it to Java 20 (on Eclipse 2023-06):
This is also true, if the plugin is not configured inside the profiles section, yet it could be argued the release option is only valid from Java 9+.
If the release tag is removed, the eclipse settings are correctly set to JDK 1.8.
Version: Eclipse 2023-06 with most current m2e at 2023-08-13, but the problem exists for a while, I just didn't know how to pin it down some months ago.
@dstango can you try if current snapshot fixes the problem or if it persists?
Also keep in mind that profile activation based on the JDK currently is performed on the JDK you run Eclipse so the java-9-plus
profile is always active!
@dstango can you try if current snapshot fixes the problem or if it persists?
Also keep in mind that profile activation based on the JDK currently is performed on the JDK you run Eclipse so the
java-9-plus
profile is always active!
Will try later when I'm home.
I'm aware about the embedded maven is running on the Eclipse jdk. Yet it should activate the jdk8 language compliance anyhow.
Original intention of the profile was as a basic 'safety net' if someone wants to build the project with a newer jdk, but the result should comply to jdk8 anyhow (I know it's not perfect).
I tried the snapshot from here: https://download.eclipse.org/technology/m2e/snapshots/latest/ for the me2-integration with Eclipse, and the problem seems to be resolved!
Before installing I played around some more and noticed the issue not to exist for release-values >8, eg. 9 or 11. When specifying release 1.8 even the non-snapshot-version behaved correctly, though not fitting with the specification here: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html
Looks like somewhere the version number handling was borrowed from the source/target tags, that accept "1.8" ... But someone seemes to have noticed that before and already fixed it.
Thank you!
I faced same issue.
Before installing I played around some more and noticed the issue not to exist for release-values >8, eg. 9 or 11. When specifying release 1.8 even the non-snapshot-version behaved correctly, though not fitting with the specification here: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html
I can confirm this.