使用Maven执行build.xml

时间:2010-05-12 08:48:11

标签: svn maven-2 svn-checkout

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

这个脚本检查了我的所有项目和子项目,我已经习惯了使用maven,之前并没有真正使用过很多蚂蚁,而且我知道ant可以和Maven一起使用。所以我的问题是:如何?

2 个答案:

答案 0 :(得分:9)

我真的不喜欢这种方法(要么使用Ant,要么使用Maven,但不能使用混蛋)但是你可以使用外部build.xmlMaven 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内,请参阅Usage页面。)

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

答案 1 :(得分:0)

您可以通过Maven-Ant Plugin执行ant脚本,但为什么需要Ant来检查项目?你有没有组织你的子项目在同一棵树?

相关问题