eclipse Ant 中的“无法创建任务或键入 antlib:org.apache.maven.artifact.ant:mvn”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32950669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Failed to create task or type antlib:org.apache.maven.artifact.ant:mvn" error in Ant
提问by Lucky
Ant build failed to run while running the ant tasks in build.xml
. I got the following error in the console:
在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
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 answeralso couldn't solve the issue.
我将 maven-ant-tasks jar 文件放在 eclipse 插件的文件夹和 WinAnt ANT_HOME/lib 目录中,也包含在类路径中。但这并没有解决我的问题,这个答案也无法解决问题。
回答by Lucky
- Create a
lib
directory in the root of your project and place the maven-ant-tasks.jarfile inside it. - Include the import statement in your
build.xml
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" />
The above steps solved my issue. Hope this is helpful to someone in the future.
以上步骤解决了我的问题。希望这对将来的某人有所帮助。
Alternate solutions,
替代解决方案,
- You can also place the
maven-ant-tasks.jar
file under theANT_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
- 您也可以将
maven-ant-tasks.jar
文件放在ANT_HOME/lib
文件夹下以解决此问题。 - 或者您可以将它放在 eclipse plugins 文件夹下。
例如。eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib
回答by DBraga
In my case, i already had the maven-ant-taksk.jar into directory 'eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib'.
就我而言,我已经将 maven-ant-taksk.jar 放入目录 'eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib'.
I'm using eclipse, so what i needed was, go to Ant Runtime on menu Windows > Preferences > Ant > Runtime, select "Ant Home Entries"
, click on "Ant Home"
button e select the Ant home directory
我正在使用 eclipse,所以我需要的是,在菜单 Windows > Preferences > Ant > Runtime 上转到 Ant Runtime,选择"Ant Home Entries"
,单击"Ant Home"
按钮 e 选择 Ant 主目录
'eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib'
It worked!
有效!