运行 ant 任务时,Ant 构建无法运行build.xml
。我在控制台中收到以下错误:
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-tasks jar 文件放置在 eclipse 插件的文件夹和 WinAnt ANT_HOME/lib 目录中,并且也包含在类路径中。但这并没有解决我的问题这个答案也无法解决问题。
- 创建一个
lib
目录放在项目的根目录中,并将maven-ant-tasks.jar文件在里面。
- 将导入声明包含在您的
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" />
上述步骤解决了我的问题。希望这对将来的人有帮助。
替代解决方案,
- 您还可以将
maven-ant-tasks.jar
文件下的ANT_HOME/lib
文件夹来解决这个问题。
- 或者您可以将其放在 eclipse 插件文件夹下。
eg. eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)