在Maven2插件中用Velocity对配置文件的集中管理
正如我在“用Velocity进行配置文件信息的集中管理 ”————http://danlley.iteye.com/blog/106130 中的许诺,这个专题将专门说说如何在Maven2插件中用Velocity对配置文件的集中管理。有了上个专题的基础,我这里也就化繁就简了。下面这段代码是通过上个专题的例子进行改写、整理、重构以后的代码,核心任务就是处理配置文件。
?
- <build>??
- ????<plugins>??
- ????????<plugin>??
- ????????????<groupId>org.danlleygroupId>??
- ????????????<artifactId>maven-velocity-pluginartifactId>??
- ????????????<version>1.0version>??
- ????????????<configuration>??
- ????????????????<template>sample_data.propertiestemplate>??
- ????????????configuration>??
- ????????????<executions>??
- ????????????????<execution>??
- ????????????????????<phase>compilephase>??
- ????????????????????<goals>??
- ????????????????????????<goal>replacegoal>??
- ????????????????????goals>??
- ????????????????execution>??
- ????????????executions>??
- ????????plugin>??
- ????plugins>??
- build>??
?
?
加入工程以后我的测试执行结果如下:
F:\workspaces\maven-velocity-lab>mvn compile
[INFO] Scanning for projects...
[INFO] -------------------------------------
---
[INFO] Building maven-velocity-lab
[INFO]??? task-segment: [compile]
[INFO] -------------------------------------
---
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [velocity:replace {execution: default}]
[INFO] +-----------------------------------------+
[INFO] |???????????? Velocity Files:???????????? |
[INFO] +-----------------------------------------+
[INFO] dlmchibernate.cfg.xml.danlley
[INFO] log4j.xml.danlley
[INFO] dlhibernate.cfg.xml.danlley
[INFO] download_config.xml.danlley
[INFO] 生成文件已经被放置在路径:F:\workspaces\maven-velocity-lab\target\classes
?请核对!
[INFO] ------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Aug 06 16:38:58 CST 2007
[INFO] Final Memory: 5M/9M
[INFO] ------------------------------------
?
参考资料:http://maven.apache.org/guides/plugin/guide-java-plugin-development.html