当前位置:   article > 正文

在工程POM中内嵌Ant脚本

ant脚本引入pom.xml
由于每篇文章的字数有限制,我没办法在同一个专题中同时将相关的问题做一个全面说明,下面接上上一个专题的内容,说明一下在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>  
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/1010533
推荐阅读
相关标签
  

闽ICP备14008679号