`
123003473
  • 浏览: 1042157 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

maven-antrun-plugin(运行ant的插件)

 
阅读更多
[转载声明] 转载时必须标注:本文来源于铁木箱子的博客http://www.mzone.cc
[本文地址] 本文永久地址是:http://www.mzone.cc/article/298.html
      ant是一个老牌的项目打包管理系统了,目前虽然已经慢慢被maven取代,但其功能的强大仍然是很多场合下的首选,尤其是众多的task可以基本满足任何需求。其实在maven中也有使用ant的需求,比如不同环境打包编译时使用不同的配置信息等,或者是说做一些文件删除、复制之类的事情,这有些是maven做不来的,而ant就可以了,况且maven中已经有了maven-antrun-plugin插件,专门为在maven中运行ant做好了准备。

      使用这个插件,只需要在项目的pom文件中定义如下插件片段:


<plugin>   
   <artifactId>maven-antrun-plugin</artifactId>    
     <executions>       
        <execution>         
             <phase>compile</phase>        
                   <goals>            
                         <goal>run</goal>        
                   </goals>             
                   <configuration>       
                         <tasks>          
                             <delete file="${project.build.directory}/classes/abc.properties" />        
                         </tasks>          
                   </configuration>        
        </execution>    
     </executions>  
</plugin>  


这里,我们在maven的编译阶段执行一些文件的删除操作,比如将测试环境的配置文件删除,复制生产环境的配置文件等等,我们都可以使用ant的task来定义。通过ant的maven插件,可以将ant的强大功能也都引入到maven中来,实现二者的强强结合。

参考文档:

1、maven-antrun-plugin插件:http://maven.apache.org/plugins/maven-antrun-plugin/

2、ant的task列表总览:http://ant.apache.org/manual/tasksoverview.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics