Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
Currently, the character encoding for reports output files needs to be configured individually for each and every plugin that creates new report types.

...



Life would become easier if there was a dedicated POM element

...

 like {{*${project.reporting.outputEncoding}{*}}} which could be used to specify the encoding once per entire project. Every plugin could use it as default value, like it has been done with [source files encoding

...

Code Block
javajava
|MAVENUSER:POM Element for Source File Encoding]:
{code:java}
/**
* @parameter expression="${encoding}" default-value="${project.reporting.outputEncoding}"
*/
private String encoding;
{code}
Adding this element to the POM structure can only happen in Maven 2.1:

...


{code
:xml
xml
}
<project>
  ...
  <reporting>
    <outputEncoding>UTF-8</outputEncoding>
    ...
  </reporting>
  ...
</project>
{code}
For  Maven 2.0.x, the value can be defined as an equivalent property:

...

Code Block
xmlxml

\\
{code:xml}
<project>
  ...
  <properties>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    ...
  </properties>
  ...
</project>
{code}
Thus plugins could immediately be modified to use {{$project.reporting.outputEncoding}} expression, whatever Maven version is used.

h2.

...

 Default Value

...



Actually, some plugins use ISO-8859-1 as default output encoding (maven-site-plugin, maven-jxr-plugin), others UTF-8 (cobertura-maven-plugin), or even platform encoding (maven-javadoc-plugin).

...



Proposed unified default value: *UTF-8*, which must be supported by every JVM (see java.nio.Charset) and will work for anybody in the world.

...



A check has to be coded in every plugin with the default value:

...


{code
:java
java
}
/**
* Gets the effective reporting output files encoding.
*
* @return The effective reporting output file encoding, never <code>null</code>.
*/
protected String getEncoding()
{
    return ( encoding == null ) ? ReaderFactory.UTF_8 : encoding;
}
{code}
This default value can be coded in POM model too for 2.1.x (default value of the encoding attribute) and in super-pom in Maven 2.0.x. But this change is only for clarity since without it, the previous check coded in every plugin will transform _null_ value to the chosen default value.

h2.

...

 Plugins to Modify

...



*Affected Apache plugins:

...

*
- maven-site-plugin

...


- maven-javadoc-plugin

...


- maven-jxr-plugin

...



*Affected Codehaus plugins:

...

*
* cobertura-maven-plugin