在build.xml中运行Ant任务时,ant build无法运行。我在控制台中得到了以下错误:
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目录中,也包含在类路径中。但是它没有解决我的问题,this answer也不能解决这个问题。
发布于 2015-10-05 22:09:25
lib目录,并将maven-ant-tasks.jar文件放入其中。build.xml中包含import语句
<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\plugins\org.apache.ant_1.8.3.v20120321-1730\lib
发布于 2018-02-05 21:27:14
在我的例子中,我已经将maven-ant- the sk.jar放到了'eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib'.目录中
我使用的是eclipse,所以我需要的是,在菜单Window> Preferences > Ant > Runtime上转到Ant Runtime,选择"Ant Home Entries",单击"Ant Home"按钮选择Ant主目录
'eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib'啊,真灵!
https://stackoverflow.com/questions/32950669
复制相似问题