ITeye博客

在工程POM中内嵌Ant脚本

danlley · 2007-07-17 22:14 · PM(Project Manage) · Markdown

由于每篇文章的字数有限制,我没办法在同一个专题中同时将相关的问题做一个全面说明,下面接上上一个专题的内容,说明一下在Maven的POM中如何内嵌Ant脚本:

具体模板为在build节点的plugins节点中加入如下代码:

xml 代码

  1. <plugin>
  2. <artifactId>maven-antrun-plugin</artifactId>
  3. <executions>
  4. <execution>
  5. <phase><!-- 内嵌的Ant脚本执行操作阶段 --></phase>
  6. <configuration>
  7. <tasks>
  8. <!-- 在这里加入你所有可以在target中执行的操作 -->
  9. </tasks>
  10. </configuration>
  11. <goals>
  12. <goal>run</goal>
  13. </goals>
  14. </execution>
  15. </executions>
  16. </plugin>

比如你要在最后生成测试报告后执行一段Ant脚本来将测试报告进行打包,可以使用如下代码:

xml 代码

  1. <plugin>
  2. <artifactId>maven-antrun-plugin</artifactId>
  3. <executions>
  4. <execution>
  5. <phase>site</phase>
  6. <configuration>
  7. <tasks>
  8. <jar destfile="target/cover-test-result.zip">
  9. <fileset dir="target/site">
  10. <include name="**/*.html" />
  11. <include name="**/*.css" />
  12. <include name="**/*.txt" />
  13. <include name="**/*.png" />
  14. <include name="**/*.js" />
  15. </fileset>
  16. </jar>
  17. </tasks>
  18. </configuration>
  19. <goals>
  20. <goal>run</goal>
  21. </goals>
  22. </execution>
  23. </executions>
  24. </plugin>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。