“无法创建任务或类型antlib:org.apache.maven.artifact.ant:mvn”蚂蚁错误 [英] "Failed to create task or type antlib:org.apache.maven.artifact.ant:mvn" error in Ant

查看:1213
本文介绍了“无法创建任务或类型antlib:org.apache.maven.artifact.ant:mvn”蚂蚁错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

build.xml 中运行ant任务时,Ant构建失败。我在控制台中收到以下错误:

Ant build failed to run while running the ant tasks in build.xml. I got the following error in the console:

Buildfile: F:\Eclipse Projects\my_project\build.xml
  [typedef] Could not load definitions from resource org/apache/maven/artifact/ant/antlib.xml. It could not be found.

BUILD FAILED
F:\my_project\build.xml:32: Problem: failed to create task or type antlib:org.apache.maven.artifact.ant:mvn
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -F:\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib
        -C:\Users\Lucky\.ant\lib
        -a directory added on the command line with the -lib argument

我将maven-ant任务jar文件放在eclipse插件的文件夹和WinAnt ANT_HOME / lib目录中,并且也包含在类路径中。但是它并没有解决我的问题,这个答案也无法解决问题。

I placed the maven-ant-tasks jar file in eclipse plugin's folder and in the WinAnt ANT_HOME/lib directory and also included in the classpath. But it didn't solve my problem and this answer also couldn't solve the issue.

推荐答案


  1. 在项目根目录下创建一个 lib 目录 maven-ant-tasks.jar 文件

  2. 在您的 build.xml中包含import语句

  1. Create a lib directory in the root of your project and place the maven-ant-tasks.jar file inside it.
  2. Include the import statement in your build.xml

<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />

上述步骤解决了我的问题。希望这对未来有帮助。

The above steps solved my issue. Hope this is helpful to someone in the future.

替代解决方案


  • 您还可以将 maven-ant-tasks.jar 文件放在 ANT_HOME / lib 文件夹下,以解决此问题。

  • 或者你可以在eclipse插件文件夹下。
    如。 eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib

  • You can also place the maven-ant-tasks.jar file under the ANT_HOME/lib folder to solve this issue.
  • Or you could have it under the eclipse plugins folder.
    eg. eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib

这篇关于“无法创建任务或类型antlib:org.apache.maven.artifact.ant:mvn”蚂蚁错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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