Maven2 Ant Plugin cannot be found

If you use Maven 2, and have been trying to use the Maven 2 Ant plugin (“mvn ant:ant“), you may have been getting the following error:

The plugin 'org.apache.maven.plugins:maven-ant-plugin' does not exist or no valid version could be found

A quick check, however, at the Maven 2 Plugin Repository shows that the maven-ant-plugin is right there. However, the latest published version is version 2.0 and for some strange reason (at least on my end) Maven doesn’t pick it up.

There is a workaround. Apparently, you can specify the full plug-in groupId, artifactId and version as mentioned in here in the maven-users mailing list. So you could go:

mvn org.apache.maven.plugins:maven-ant-plugin:2.0:ant

Better yet, simply configure the plugin through in your project’s pom.xml:

<build>
  <plugins>
  ...
    <plugin>
      <artifactId>maven-ant-plugin</artifactId>
      <version>2.0</version>
    </plugin>
  ...
  </plugins>
  ...
</build>

(Note that the plugin groupId, when not specified, defaults to org.apache.maven.plugins which is correct, in this case.)

That should let you do mvn ant:ant again any time!