Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way I can use Maven repositories to add dependencies to Ant?

Tags:

maven-2

ant

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?

like image 453
benstpierre Avatar asked Sep 14 '09 15:09

benstpierre


People also ask

Can Ant download dependencies?

In a previous article I stepped through development of an Ant script to build a target JAR file and run unit tests against it. Where we left off, the project depended on the developer manually populating a library directory with JUnit and its dependency.

Which file is used to define dependency in Ant?

The first time the build is run, the dependencies will be resolved from the repository, and the task will generate a file called "build-dependencies. xml". This file contains a list of the properties and fileset references generated during the build.

How do I add a dependency in Maven?

Add a Java Maven Dependency to the Utility ProjectRight-click the utility project, and select Maven>Add Dependency. Type a dependency name in the Enter groupID… field (e.g., commons-logging) to search for a dependency. Select the dependency, and click OK.

How do I use Maven repository?

Downloading from a Remote RepositoryDownloading in Maven is triggered by a project declaring a dependency that is not present in the local repository (or for a SNAPSHOT , when the remote repository contains one that is newer). By default, Maven will download from the central repository.


1 Answers

The Maven application has a set of Ant tasks that can be 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.

2021 Update:

That said, stop using Ant. It's an archaic build tool that is much better being replaced by Maven, Gradle, or any of their descendants.

like image 174
Jherico Avatar answered Oct 04 '22 17:10

Jherico