为了账号安全,请及时绑定邮箱和手机立即绑定

如何在maven中使用ant

如何在maven编译时候运行ant脚本?

使用专门的antrun插件,并且在target标签内部加入ant的代码

      <plugin>         <artifactId>maven-antrun-plugin</artifactId>         <version>1.6</version>         <executions>           <execution>             <phase> <!-- 生命周期阶段 --> </phase>             <configuration>               <target>                 <!-- 加入target内部的代码 -->               </target>             </configuration>             <goals>               <goal>run</goal>             </goals>           </execution>         </executions>       </plugin>

如何在ant脚本中引用maven的classpath?

maven给每一个依赖都生成了一个属性,格式为"groupId:artifactId[:classifier]:type",比如,如果一下例子就显示依赖的org.apache.common-util的jar文件路径

<echo message="Dependency JAR Path: ${org.apache:common-util:jar}"/>

另外,maven还预定义了四个classpath的引用,他们是

maven.compile.classpath maven.runtime.classpath maven.test.classpath maven.plugin.classpath

如何使用antrun插件运行外部的build文件?

很简单,直接在antrun里边使用ant指令即可,如下:

<plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-antrun-plugin</artifactId>     <version>1.6</version>     <executions>         <execution>             <id>compile</id>             <phase>compile</phase>             <configuration>                 <target>                     <!-- 同时传递内置的classpath给外部ant文件 -->                     <property name="compile_classpath" refid="maven.compile.classpath"/>                     <property name="runtime_classpath" refid="maven.runtime.classpath"/>                     <property name="test_classpath" refid="maven.test.classpath"/>                     <property name="plugin_classpath" refid="maven.plugin.classpath"/>                          <ant antfile="${basedir}/build.xml">                         <target name="test"/>                     </ant>                 </target>             </configuration>             <goals>                 <goal>run</goal>             </goals>         </execution>     </executions> </plugin>

如何在ant中使用maven的功能?

使用ant的maven task,不过只有ant 1.6以上和jdk 1.5环境才支持。

原文链接:http://outofmemory.cn/maven/FAQ/how-to-interact-with-ant-in-maven

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消