使用Maven执行build.xml

Gan*_*row 13 svn maven-2 svn-checkout

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

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

Pas*_*ent 9

我真的不是这种方法的忠实粉丝(要么使用Ant,要么使用Maven,而不是使用混蛋)但是你可以使用外部build.xmlMaven AntRun插件:

<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>
Run Code Online (Sandbox Code Playgroud)

然后运行mvn antrun:run(或者将配置放在一个内部,execution如果你想将AntRun插件绑定到生命周期阶段,请参阅Usage页面).

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