用Maven执行build.xml [英] Execute build.xml with Maven

查看:841
本文介绍了用Maven执行build.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Maven执行build.xml脚本?

Is it possible to execute build.xml script with Maven?

该脚本签出了我所有的项目和子项目,我刚刚习惯于使用maven,之前并没有真正使用过太多的ant,我知道ant可以与maven一起使用.所以我的问题是:如何?

This script checksout all my projects and subprojects and I've just got used to using maven, didn't really use much of an ant before and I know ant can be used with Maven. So my question is: how?

推荐答案

我真的不是这种方法的忠实拥护者(可以使用Ant或Maven,但不要混混),但是您可以使用外部 Maven AntRun插件:

I'm really not a big fan of this approach (either use Ant, or Maven, but not a bastard mix) but you can use an external build.xml with the Maven AntRun Plugin:

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <configuration>
          <tasks>
            <taskdef resource="net/sf/antcontrib/antcontrib.properties"
              classpathref="maven.plugin.classpath" />
            <ant antfile="${basedir}/build.xml">
              <target name="test"/>
            </ant>
          </tasks>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>ant-contrib</artifactId>
            <version>1.0b3</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</project>

然后运行mvn antrun:run(如果要将AntRun插件绑定到生命周期阶段,则将其放入execution中,请参考

And then run mvn antrun:run (or put the configuration inside an execution if you want to bind the AntRun plugin to a lifecycle phase, refer to the Usage page).

更新:如果您使用的是来自ant-contrib的内容,则需要将其声明为插件的依赖项.我已经更新了插件配置以反映这一点.还要注意我添加的taskdef元素(虽然我不确定您是否需要classpathref属性).

Update: If you are using things from ant-contrib, you need to declare it as dependency of the plugin. I've updated the plugin configuration to reflect this. Also note the taskdef element that I've added (I'm not sure you need the classpathref attribute though).

这篇关于用Maven执行build.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆