Take the 2-minute tour ×

I was wondering if anybody has seen a technique for adding Maven dependencies to Ant. I thought that Ivy was meant to do this but then I realized that it is only an Ant-style tool for dependency management.

It seems to me that if somebody extended Ant to be able to reference Maven dependencies (perhaps only for open source libraries) Ant could piggyback at least one great feature of Maven without having to re-invent the wheel.

Any thoughts?

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

The Maven has a set of Maven ant tasks that can downloaded and placed in your Ant lib directory. After that, you can declare a classpath in Ant that is defined by the dependencies in your POM. This is an example of what you can declare in your build.xml.

<artifact:dependencies filesetId="deps.fileset" type="jar">
  <pom file="mypom.xml"/>

More details can be found here and here.

share|improve this answer
This is awesome! –  Benju Sep 14 '09 at 18:24
add comment

There are a set of ant tasks for Mercury that allow you to perform dependency management tasks, specify configuration (e.g. server credentials), modify/alter the ant path and write to the repository. See this blog for details.

There are also Maven tasks for ant, though they are not as fully featured. Maven is moving towards Mercury (particularly for Maven3) so it makes sense to use the Mercury tasks.

The following configuration reads the dependencies from the specified pom and populates the specified variable with the resultant path:

<path id="my.compile.path">
    <dependency name="groupId:artifactId:1.0::pom" 
share|improve this answer
add comment

Agree with Jherico's answer - the Maven Ant Tasks. Refer this: Why you should use the Maven Ant Tasks instead of Maven or Ivy

It has detailed examples, which should get you going.

share|improve this answer
add comment

Your Answer


