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

State default source (1.3) and target (1.1) in the documentation

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.1
    • Labels:
      None

      Description

      The documentation does currently say nothing about the compiler defaults, especially source and target version, which is 1.3 and 1.1 (byte code 45.3). It would be helpful to add this information to the docs to make the defaults obvious.

      Respective mailing list content:

      This has been discussed several times on this list.

      IMO, the default compilation target being 1.1 (or another hard-defined
      version) meets the rule of least surprise. You can argue that you
      don't like 1.1 and you'd prefer 1.3 or even 1.5 but that is another
      discussion.

      In contrast, the rule of most surprise would be "my build changes when
      I change my JDK" or "my build changes when I build things on different
      machines". This is the absolute worst thing you can run into when
      trying to standardize and control your build process.

      If you want to target a specific JDK, then simply add the compiler
      configuration in your poms. If you feel this has not been documented
      sufficiently, then post a RFE in Jira and someone will add some text
      to the proper page(s) on the site.

      Wayne

      On 8/15/07, Gisbert Amm <gia@webde.de> wrote:

      >> Searching for version issues, I had a closer look at the *.class files
      >> generated by Maven2 with the default compiler settings and found that
      >> the first bytes of them are "cafe babe 0003 002D ...", which is byte
      >> code version 45.3 = Java 1.1.
      >>
      >> First I was believing that I had this (target 1.1) configured somewhere
      >> by accident. However, I didn't find any such configuration, therefore I
      >> dug into the plexus-compiler source and found the following in
      >> plexus-site/plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java:
      >>
      >> // TODO: this could be much improved
      >> if ( StringUtils.isEmpty( config.getTargetVersion() ) )
      >>

      { >> // Required, or it defaults to the target of your JDK (eg 1.5) >> args.add( "-target" ); >> args.add( "1.1" ); >> }

      >> else
      >>

      { >> args.add( "-target" ); >> args.add( config.getTargetVersion() ); >> }

      >>
      >> if ( !suppressSource( config ) && StringUtils.isEmpty(
      >> config.getSourceVersion() ) )
      >>

      { >> // If omitted, later JDKs complain about a 1.1 target >> args.add( "-source" ); >> args.add( "1.3" ); >> }

      >>
      >> Is there any particular reason why target is set to 1.1 here? IMHO, it
      >> breaks the rule of least surprise for I am certainly expecting that the
      >> generated byte code by default has the version of the JDK I'm using the
      >> compiler of. The comment "Required, or it defaults to the target of your
      >> JDK" doesn't give any reason. Does anybody know, why this default is set?
      >>
      >> At least it should be mentioned on
      >> http://maven.apache.org/plugins/maven-compiler-plugin/howto.html to make
      >> it obvious to users. Otherwise people might have problems and need a
      >> long time to find out what's going on (see
      >> http://www.nabble.com/Odd-Compilation-Issue-tf1566644s177.html#a4287495
      >> for an example).
      >>
      >> Regards,
      >> Gisbert

        Issue Links

          Activity

          Gisbert Amm created issue -
          Stefano Lenzi made changes -
          Field Original Value New Value
          Link This issue relates to MCOMPILER-6 [ MCOMPILER-6 ]
          Gisbert Amm made changes -
          Attachment MCOMPILER-57-maven-compiler-plugin.patch [ 29597 ]
          Dennis Lundberg made changes -
          Assignee Dennis Lundberg [ dennislundberg ]
          Dennis Lundberg made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Dennis Lundberg made changes -
          Affects Version/s 2.1 [ 12304 ]
          Affects Version/s 2.0.2 [ 12484 ]
          Fix Version/s 2.1 [ 12304 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 09:20:51 UTC 2015 [ 1428225651644 ]
          Mark Thomas made changes -
          Workflow jira [ 12718573 ] Default workflow, editable Closed status [ 12750066 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 22:48:53 UTC 2015 [ 1428274133206 ]
          Mark Thomas made changes -
          Workflow jira [ 12956008 ] Default workflow, editable Closed status [ 12993069 ]
          Mark Thomas made changes -
          Assignee dennislundberg [ dennislundberg ] Dennis Lundberg [ dennisl@apache.org ]

            People

            • Assignee:
              Dennis Lundberg
              Reporter:
              Gisbert Amm
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development