Maven Compiler Plugin
  1. Maven Compiler Plugin
  2. MCOMPILER-125

Maven should not set default Java source target level

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0, 2.0.1, 2.0.2, 2.1, 2.2
    • Fix Version/s: None
    • Labels:
      None

      Description

      Expectation:
      The Maven Compiler Plugin, as it is just a wrapper of the underlying compiler (javac by default), should not change the default source/target levels of the underlying compiler, or specifying any hard coded values, FOR the user.

      Fact:
      As described in the plugin homepage (http://maven.apache.org/plugins/maven-compiler-plugin/index.html), "The default source setting is 1.3 and the default target setting is 1.1, independently of the JDK you run Maven with."
      And people have been complaining against this, For that the default source/target levels are either inappropriate or outdated. See MCOMPILER-80, MCOMPILER-46, MCOMPILER-124. Plus that MCOMPILER-80 has been re-opened recently soon after it's fixed.
      Up to now, the filed issues are all about to change the default source/target levels to more 'current' values, but whatever the values are set to, they will sooner or later fall out of date, this is why we have several requests like this over time, as listed above. They all represent a resolution for 'now', not for all the time.
      On the contrary, Ant is doing this as expected, As in http://ant.apache.org/manual/CoreTasks/javac.html, it always defaults the source/target levels to the javac in use, and clarifies that the users are "highly recommended to always specify them".
      And As a result, Ant never gets complaints regarding the issues we filed against Maven Compiler Plugin.
      Additionally, Eclipse is using the default values from the JDK in use as well. if we create a project with mvn archetype:generate, then mvn eclipse:eclipse and import it into Eclipse, you'll see that Eclipse does it like Ant. Keep the project open in Eclipse and do a mvn compile outside (or phases that depend on it, such as mvn package), you'll see a weird compile error in Eclipse with no obvious clue. At the beginning you won't 'see' that the problem is caused by Maven, to be specific, the source/target levels set by Maven FOR you.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            redstun
          • Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:

              Development