Search code examples
mavenbuildant

java.lang.NoSuchMethodError on <artifact:dependencies> tag


I am trying to invoke ant build using maven and trying to call the below from the ant target

<artifact:dependencies pathId="war.lib.path" useScope="runtime">
    <pom file="pom.xml" />
</artifact:dependencies>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <configuration>
                        <target>
                            <ant antfile="${basedir}/build/build.xml">
                                <target name="build" />
                            </ant>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

This is giving me the following error:

Caused by: java.lang.NoSuchMethodError: org.apache.maven.settings.RuntimeInfo.<init>(Lorg/apache/maven/settings/Settings;)V

    at org.apache.maven.artifact.ant.AbstractArtifactTask.readSettings(AbstractArtifactTask.java:382)
    at org.apache.maven.artifact.ant.AbstractArtifactTask.loadSettings(AbstractArtifactTask.java:311)
    at org.apache.maven.artifact.ant.AbstractArtifactTask.initSettings(AbstractArtifactTask.java:278)
    at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:750)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    ... 66 more

Can you let me know what is wrong Edit 1: The. Maven Version used is 3.1.1 and tried with ant plugin 1.8 and 3.0.0 still getting the same error. here is the plugin used in pom.xml


Solution

  • It looks like you are using dependencies task from the Maven Ant Tasks component, which is retired and no longer maintained since at least May of 2014.

    You should either downgrade the version of Maven, which I assume is version 2 based on the date of the last update of the component.

    Or migrate your Ant build scripts to the Maven Artifact Resolver Ant Tasks , as recommended at Maven Ant Tasks.