tags:

views:

119

answers:

3

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?

+4  A: 

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"/>
</artifact:dependencies>

More details can be found here and here.

Jherico
This is awesome!
Benju
+1  A: 

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">
  <deps>
    <dependency name="groupId:artifactId:1.0::pom" 
        pom="${basedir}/artifactId-1.0.pom"/>
  </deps>
</path>
Rich Seller
A: 

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.

Peter Thomas