In some cases, you may need to generate Ant build file (build.xml) for your project integration purpose. For example, the klockwork code analysis tool is required Ant file to perform the static code analysis processes for java project.

Maven Ant plugin

Maven comes with a handy Ant plugin to generate Ant build file from Maven pom.xml easily. Locate your pom.xml file, and issue the command : mvn ant:ant.

D:\Project_ABC>mvn ant:ant

Output

D:\Project_ABC\SWP>mvn ant:ant
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'ant'.
[INFO] artifact org.apache.maven.plugins:maven-ant-plugin: checking for updates from central
...
[INFO] ------------------------------------------------------------------------
[INFO] Building abc
[INFO]    task-segment: [ant:ant]
[INFO] ------------------------------------------------------------------------
...
Downloading: http://repo1.maven.org/maven2/xalan/xalan/2.7.0/xalan-2.7.0.pom
491b downloaded
...
Downloading: http://repo1.maven.org/maven2/xalan/xalan/2.7.0/xalan-2.7.0.jar
2666K downloaded
[INFO] [ant:ant]
[INFO] Wrote Ant project for ABC to D:\Project_ABC
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28 seconds
[INFO] Finished at: Thu Feb 12 16:16:15 SGT 2009
[INFO] Final Memory: 9M/16M
[INFO] ------------------------------------------------------------------------

Done

Maven just created 3 Ant files – build.xml, maven-build.xml and maven-build.properties.

Note
For more detail, please visit to this Maven’s Ant plugin official page
Tags :
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider making a donation to the charity, thanks.

Related Posts

Popular Posts