views:

234

answers:

5

I have a project that is built and managed by Maven. I have a second project that has an ant build. I'd like to reference the maven project from the ant project and pull in all of the required dependencies. Can anyone suggest a way to do this?

thanks,

Jeff

+2  A: 

You can use Ivy:

Ivy can therefore be used to bring the dependency management feature of maven to Ant build files, for those of you who already use Ant and who do not want to setup a maven project.

Dan Dyer
+1  A: 

Apache Ivy is an Ant library that can handle Maven-style repositories.

Here's a page which describes the differences between them and how to integrate the two.

skaffman
+3  A: 

The maven-ant-tasks work quite well for this sort of thing.

Dominic Mitchell
+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>

You can also use the Mercury tasks to deploy to a Maven repository using an Ant build file:

<repo id="myRepository" 
    url="http://localhost:8081/nexus/content/groups/public"&gt;
    <auth name="myUser" pass="myPassword"/>
</repo>

<write repoid="myRepository"
       name="my.group.id:my-artifact-id:1.0"
       file="${basedir}/target/my-artifact-id.jar"/>
Rich Seller
A: 

I blogged in detail on how to do this here:

Why you should use the Maven Ant Tasks instead of Maven or Ivy

Peter Thomas