File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Help in writing an ANT task. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Help in writing an ANT task. " Watch "Help in writing an ANT task. " New topic
Author

Help in writing an ANT task.

Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 266
Hi Friends,

Currently my project uses Maven for build. But now we want to use Ant for the build purposes. We now have a requirement to write an Ant task to take the update of the jar files using Maven whenever Ant build file is run.
Please help me in writing an ANT task for the same.

Note: On my own I searched the net and tried to implement it but didn't get much success.

Please Help.


Thanks and Regards,
Sid.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30752
    
156

That seems like an odd requirement. Most people go from Ant to Maven and not vice versa. Also, your requirement says that you still want to use the Maven repository for your Ant build. It's not impossible though to do what you want. I just wonder what Ant + Maven repo buys you over Maven. And whether it could be better accomplished via having Ant code in your Maven pom.

On to your question. You can use dependency:get in order to pull jars without having a Maven POM. For example:
mvn -DgroupId=com.group -DartifactId=the-jar -Dversion=1.0.0 dependency:get

Which means you can write an Ant task that loops through a desired list of jars and uses <exec> to run Maven commands.

Alternatively, you could create a pom.xml for your dependencies, run it and then copy over the jars (via the assembler plugin) into your Ant build.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42274
    
  64
What, specifically, are you struggling with? Are you asking about creating an Ant task using pre-built tasks, or writing your own in Java? If the latter, start at http://www.coderanch.com/how-to/java/AntTask


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help in writing an ANT task.