Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Failed to create task or type antlib:org.apache.maven.artifact.ant:mvn" error in 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

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.

like image 325
Lucky Avatar asked Oct 05 '15 14:10

Lucky


People also ask

Why did my build fail in Maven?

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.

Do I need Ant Ivy plugin with Ant build tool?

This means that you not only have to have Ant Build tool installed on your system, but you also need to have the Ant Ivy plugin installed to it. We mention this in the readme file in the root folder of the project, where we direct people to the Ant documentation for installing Ivy.

Why does build fail to create a task?

BUILD FAILED /home/russ/blackpearl/fun/build.xml:121: Problem: failed to create task or type sqlscriptpreprocessor Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared.

How to add Maven-Ant-tasks to a JAR file?

Create a lib directory in the root of your project and place the maven-ant-tasks.jar file inside it. Include the import statement in your build.xml The above steps solved my issue.


1 Answers

  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.

Alternate solutions,

  • 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
like image 137
Lucky Avatar answered Sep 20 '22 20:09

Lucky