Jeff Storey
Jeff Storey

Reputation: 57192

ant/maven integration

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

Upvotes: 3

Views: 1334

Answers (4)

Rich Seller
Rich Seller

Reputation: 84038

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">
    <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"/>

Upvotes: 1

Dominic Mitchell
Dominic Mitchell

Reputation: 12289

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

Upvotes: 4

skaffman
skaffman

Reputation: 403471

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.

Upvotes: 1

Dan Dyer
Dan Dyer

Reputation: 54475

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.

Upvotes: 2

Related Questions