使用Maven执行Ant任务 [英] Execute Ant task with Maven

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

问题描述

我正在尝试使用Maven执行一些使用Ant任务编写的测试.我生成了将任务导入Maven所需的文件,但无法执行.

I'm trying to execute with Maven some test written using Ant tasks. I generated the files required to import the task into Maven, but I can't execute them.

我的POM是这样定义的:

My POM is defined this way:

<build>
  <plugins>
      <plugin>
        <artifactId>maven-ant-plugin</artifactId>
        <version>2.1</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>
                <echo message="Hello, maven"/>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

我尝试执行该消息,但运行时出现错误:

I try to execute that message, but I get an error with run:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] 'run' was specified in an execution, but not found in the plugin

但是,如果我运行:"mvn antrun:run",我知道这无法运行任务.

But, if I run: "mvn antrun:run", I know that this can not run the task.

如果我有不同的目标,该如何从Maven中调用它们?我有pom.xml,还有带有蚂蚁任务的build.xml.

An if I've different targets, how do I call them from Maven? I've the pom.xml, and build.xml with the ant tasks.

谢谢.

贡萨洛

推荐答案

要从Maven 2中运行Ant任务,您需要使用

To run Ant tasks from within Maven 2, you need to use the Maven AntRun Plugin:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.3</version>
      <executions>
        <execution>
          <phase>generate-sources</phase>
          <configuration>
            <tasks>
              <echo message="Hello, maven"/>
            </tasks>
          </configuration>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Maven Ant插件是另一回事,它是用于从POM生成Ant的构建文件.

The Maven Ant Plugin is something else, it is used to generate build files for Ant from the POM.

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

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