maven项目构建:maven-antrun-plugin插件实现文件内容拷贝和文件重命名
来源:互联网 发布:机械电子行业就业知乎 编辑:程序博客网 时间:2024/06/05 06:24
之前的文章“profile与资源过滤”介绍过,通过激活不同的profile,可以改变同一个文件中的${propertyName}占位符。也就是说:通过profile与资源过滤,我们实现了:同一个文件,打包到不同的环境,文件的内容不同。
我们项目有这样的场景:我们知道log4j框架会自动加载classpath下的log4j.properties文件。我们开发环境和生产环境的日志配置文件名是:log4j-dev.properties,log4j-online.properties,虽然这2个文件都在classpath下,但是log4j并不会自动去加载,因为文件名称不是log4j.properties。
也就是说,我们想实现这样的效果:打dev环境的包时候,将log4j-dev.properties复制到log4j.properties;打online环境的包时候,将log4j-online.properties复制到log4j.properties。这样启动项目的时候,log4j框架就能自动加载配置文件了。通过maven-antrun-plugin插件可以实现这样的需求:
<!--${log.conf}读取profile下的属性值--><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-antrun-plugin</artifactId><version>1.8</version><executions><execution><phase>compile</phase><goals><goal>run</goal></goals><configuration><tasks><move file="${project.build.directory}/classes/${log.conf}" tofile="${project.build.directory}/classes/log4j.properties" /></tasks></configuration></execution></executions></plugin>
0 0
- maven项目构建:maven-antrun-plugin插件实现文件内容拷贝和文件重命名
- maven-antrun-plugin插件
- Maven 插件之 maven-antrun-plugin
- maven-antrun-plugin(运行ant的插件)
- maven-antrun-plugin
- maven-antrun-plugin
- Maven antrun plugin 学习
- maven-antrun-plugin
- Maven实战之antrun插件
- Maven实战之antrun插件
- Apache Maven项目提供的AntRun插件详解
- Apache Maven项目提供的AntRun插件详解
- Maven antrun plugin调用Ant Optional Task
- Versions Maven Plugin 管理项目重命名版本号
- Maven profile结合Maven AntRun Plugin实现不同环境配置文件分离打包
- Idea 配置maven-tomcat-plugin插件实现项目部署
- 如何在maven-antrun-plugin中使用if条件标签
- 多maven项目重命名
- MySQL主从同步校验与重新同步
- Fork/Join框架
- 轮回 第二章 冷傲天
- PHP开发实习生任职要求(58)的总结
- Html与CSS样式——2
- maven项目构建:maven-antrun-plugin插件实现文件内容拷贝和文件重命名
- TimeUnit
- STL笔记之priority_queue 优先级队列
- 轮回 第三章 不祥?
- 轮回 第四章 诡异
- busybox的使用
- 关于IDEA中maven刷新,无法拉下JAR包的处理
- 笔记本ubuntu安装xen之殇
- html颜色代码