Eclipse-Maven Forcefully Overwrites Java Version Set Every Update Project

29 Views Asked by At

What are the details of your problem?

Why does Eclipse's Maven's plug-in overwrite the Java version set with a lower version?

When the Eclipse Maven-plugin runs Project Update..., the JDK gets switched from 11 to 8. This causes Java version 11+ stuff in the code to break and unable to compile or run. When I try to switch the project back to 11+ and compile, the Maven dependency imports break. To get the Maven packaged packages from Nexus, I end up running Project Update to resolve. This causes Eclipse-Maven to set the JDK to 8. The project needs Java-11 or higher.

What needs to happen to allow the Maven dependencies to resolve and the correct Java version be used?

Environment Versions:

  1. Eclipse: 2023-06 (4.28.0)
  2. Java-8: 1.8.0_301
  3. Java-11: 11.0.15.1
  4. Maven: 3.9.1/3.9.100.20230519-1558 (EMBEDDED)
  5. OS: Windows 10

What did you try and what were you expecting?

  1. Running Maven mvn compile , mvn install , mvn package, mvn clean compile and any other combinations anyways
    1. Result: Maven Build Failed
      1. Project has been able to run before even when the Eclipse-Maven-plugin did not work
  2. Changing the Eclipse-Project-Properties: Java Build Path , Java Code Style , Java Compiler ; to be JDK-11
    1. Java Build Path

      1. Editing the JRE-Selection with its System library selection: Execution environment , Alternate JRE , and Workspace default JRE (which I set with the Eclipse-Preferences)

        1. Result: Maps, Lists, and other Java imports break
      2. Removing and Readding the JRE System Library

        1. Result: Maps, Lists, and other Java imports break
      3. Checkbox-Selecting in Order and Export for Maven Dependencies and JRE System Library

        1. Result: Nothing notable to the situation changed
    2. Java Code Style

      1. Enabling and Disabling explicit Enable project specific settings to Java-11

        1. Result: No notable changes
    3. Java Compiler

      1. Enabling and Disabling explicit Enable project specific settings to Java-11

        1. Result: Maps, Lists, and other Java imports break
  3. Adding the POM Java Versions in the properties.java.version and properties.maven.compiler.[source, target]
    1. Result: No Change
  4. Setting JAVA_HOME is jdk-11
    1. Result: no change (correct location)
  5. Reverting back the Eclipse-Maven changes in .classpath XML for its classpath.classpathentry for the org.eclipse.jdt.launching to be <attribute name="maven.pomderived" value="true"/> and no reference to JavaSE-1.8
    1. Result: Eclipse-Maven reverts this back
  6. Editing org.eclipse.jdt.core.prefs to explicitly be Java 11 and/or remove references to "1.8"
    1. Result: Eclipse-Maven reverts this back
  7. Checking Oomph wasn't setting the Java version in org.eclipse.oomph.setup/setup/user.setup
    1. Result: No reference to Java or its versions
0

There are 0 best solutions below