关于pom文件中的project.reporting.outputEncoding配置

    在学习使用pom文件的时候,对于project.reporting.outputEncoding的配置项,经常看到出现在许多项目中,但是对于它能具体有什么作用却不是很清楚。一番查询后得知:
参考文章(外网)

以下引用为原文复制内容:

Currently, the character encoding for reports output files needs to be
configured individually for each and every plugin that creates new
report types (i.e. don’t write its content through Doxia but write
directly its files to disk).
(翻译:当前,需要为每个创建新报告类型的插件分别配置报告输出文件的字符编码(即,不要通过Doxia写入其内容,而是直接将其文件写入磁盘)。)

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;

(翻译:如果有一个专用的POM元素(如$ {project.reporting.outputEncoding}),则可以简化整个项目的工作,从而使生活更轻松。 每个插件都可以将其用作默认值,就像对源文件进行编码一样:)

    对此,我的理解是在Maven的一些插件使用中需要输出一些报告,而输出报告的编码格式是需要我们进行设定的,因为这些插件的默认编码不是统一的(后面会提到)。在此需求上,希望能提供一种更为轻松简单的方式进行配置,即使用一个默认值来控制所有的报告输出的编码。

    因此,project.reporting.outputEncoding的可以实现该需求。

    在将来还可能出现另一种方式的相同效果的配置:

Adding this element to the POM structure without breaking backward compatibility can only happen in a future version, yet to be defined (at least after Maven 3.0):
意思是:这种配置方式可能在未来的Maven版中出现,且该版本至少3.0。【但翻官网的时候看到都快4.0了,貌似还没听到什么消息(→_→)】

<project>
  ...
  <reporting>
    <!-- NOTE: This is just a vision for the future, it's not yet implemented: see MNG-3608 -->
    <outputEncoding>UTF-8</outputEncoding>
    ...
  </reporting>
  ...
</project>

For Maven 2.x and 3.x, the value can be defined as an equivalent property:
(翻译:对于Maven 2.x和3.x,可以将该值定义为等效属性:)

<project>
  ...
  <properties>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    ...
  </properties>
  ...
</project>

    也就是说这两种配置方式实现的效果是一致的,只不过前者的方式在未来的版本中可能会出现;而后者针对现在的2.x和3.x版本可以进行使用。

Default Value
Actually, default output encoding vary between plugins:
(翻译:实际上,默认输出编码在各个插件之间有所不同:)

  • ISO-8859-1 for maven-site-plugin, maven-jxr-plugin and by extension every reporting plugin generating content with maven-site-plugin’s template (that is the vast majority of reporting plugins),
  • UTF-8 for cobertura-maven-plugin,
  • platform encoding for maven-javadoc-plugin.

    以上即为我所了解到的内容,作为学习在此记录。如果你有不同的看法或者意见,还望不吝赐教。

  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值