“Failed to create task or type antlib:org.apache.maven.artifact.ant:mvn” error in Ant

前端 未结 2 1879
长发绾君心
长发绾君心 2021-01-12 01:11

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

<         


        
相关标签:
2条回答
  • 2021-01-12 01:44
    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
    0 讨论(0)
  • 2021-01-12 01:53

    In my case, i already had the maven-ant-taksk.jar into directory '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\plugins\org.apache.ant_1.8.3.v20120321-1730\lib'
    

    It worked!

    0 讨论(0)
提交回复
热议问题