读书人

maven pom中运用 native2ascii-maven-

发布时间: 2012-06-29 15:48:46 作者: rapoo

maven pom中使用 native2ascii-maven-plugin 插件来进行properties转码
背景:

原先开发的时候,需要?ant运行?copyResources?target(deploy depend 该?target?) 来进行?native2ascii?


开发过程中有时候会遗漏这个步骤,会发现 缺少相关?properties 文件并且,原来的messages文件夹 是独立于src/main/resources 之外的,独立于maven管理系统,不利于tomcat/jetty插件的集成
解决:将message文件夹移动到src/main/resources?目录引入native2ascii-maven-plugin 插件 ,在 maven ?生命周期(compile) 阶段 ,进行自动 native2ascii?,不需要额外的手工点击? ant? target ??
原先的?copyResources ?target 删除
具体实现:

? ? ? ? ?<plugin>

?????????????<groupId>org.codehaus.mojo</groupId>

?????????????<artifactId>native2ascii-maven-plugin</artifactId>

?????????????<version>1.0-beta-1</version>

?

?????????????<executions>

????????????????<execution>

???????????????????<id>native2ascii</id>

???????????????????<phase>compile</phase>

???????????????????<goals>

??????????????????????<goal>native2ascii</goal>

???????????????????</goals>

???????????????????<configuration>

??????????????????????<encoding>utf-8</encoding>

??????????????????????<includes>

?????????????????????????<include>${native2ascii_pattern}</include>

??????????????????????</includes>

???????????????????</configuration>

????????????????</execution>

?????????????</executions>

?????????</plugin>


扩展知识:

还可以使用maven-antrun-plugin 插件,配置native2ascii来实现(缺点:会比较文件时间,需要额外配置先删除再native2ascii)或者安装eclipse?proper 插件,会自动转码(缺点:源文件native2ascii)

读书人网 >软件架构设计

热点推荐