Uploaded image for project: 'Maven Compiler Plugin'
  1. Maven Compiler Plugin
  2. MCOMPILER-63

Provide specific default value for "encoding" parameter

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 2.0.2
    • None
    • None
    • Patch

    Description

      As stated in the javac doc, the parameter "encoding" defaults to the platform's default encoding if not specified. This might be a convenient feature when running javac directly from the console prompt (less typing) but I consider this harmful for an automated build. The platform's default encoding might easily differ between machines/developers, causing unreliable build output.

      Maven has "reproducible builds" on its banner and as such, locking down all plugin versions has recently become a best practice. Likewise, the encoding used to process source files should be locked down. As Maven furthermore prefers convention over configuration, such a lockdown should be provided out-of-the-box.

      The attached patch adds a default value for the encoding that locks the encoding down to "ISO-8859-1" if not explicitly overriden by the user in the POM. I chose Latin-1 for consistency with the behavior of the Maven Site Plugin although I personally would have preferred UTF-8.

      Releasing the patch might break existing builds where users have relied on their platform's default encoding for handling Non-ASCII sources. The group of those people is hopefully small and their build can be easily fixed by updating the POM.
      Not emulatable would be the possibility to explicitly use the platform's default encoding as now but I do not think that there is really somebody out there playing russian roulette with the build output... Besides, now one requested such a risky thing for the Maven Site Plugin.

      Attachments

        1. source-encoding.patch
          0.6 kB
          Benjamin Bentmann

        Issue Links

          Activity

            People

              bentmann Benjamin Bentmann
              bentmann Benjamin Bentmann
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: