Search code examples
mavenpluginsant

maven resolver having issues : failed to create task or type resolve


I am trying to using the maven resolver in trying to migrate my ant projects to maven and using the below resolver tags:

<resolve failOnMissingAttachments="true">
    <dependencies>
        <dependency coords="org.apache.maven:maven-profile:2.0.6" />
        <exclusion artifactId="junit" />
        <exclusion groupId="org.codehaus.plexus" />
    </dependencies>
    <path refid="war.lib.path" classpath="runtime" />
</resolve>

instead of using the following :
<!-- retrieve depending libraries -->
<artifact:dependencies pathId="war.lib.path" useScope="runtime">
    <pom file="pom.xml" />
</artifact:dependencies>

However I am getting the following error in replacing with maven ant resolver tasks:

Problem: failed to create task or type resolve
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.

Solution

  • You are missing information to reproduce your issue.

    However, with this minimalistic build.xml for demonstration, I got it going:

    <?xml version="1.0" encoding="UTF-8"?>
    <project basedir="." name="maven-ant-task-resolver-demo" xmlns:r="antlib:org.apache.maven.resolver.ant">
      
      
      <target name="resolve">
          
          <property name="maven.ant.resolver.version" value="1.3.0"/>
          <property name="maven.ant.resolver.jar.name"
              value="maven-resolver-ant-tasks-${maven.ant.resolver.version}-uber.jar"/>
          
          <get
              src="https://repo1.maven.org/maven2/org/apache/maven/resolver/maven-resolver-ant-tasks/${maven.ant.resolver.version}/${maven.ant.resolver.jar.name}"
              dest="." usetimestamp="true"/>
          
          <taskdef uri="antlib:org.apache.maven.resolver.ant"
              resource="org/apache/maven/resolver/ant/antlib.xml"
              classpath="./${maven.ant.resolver.jar.name}"/>
          
          <r:resolve failOnMissingAttachments="true">
              <dependencies>
                  <dependency coords="org.apache.maven:maven-profile:2.0.6" />
                  <exclusion artifactId="junit" />
                  <exclusion groupId="org.codehaus.plexus" />
              </dependencies>
              <path refid="war.lib.path" classpath="runtime" />
              
          </r:resolve>
          
          
          
      </target>
      
    </project>