In some cases, you may need an Ant build file (build.xml) for your project integration purpose. For example, the klockwork code analysis tool is required a Ant file from Java project to identify the critical issues in their code early in the development process.

1. Maven Ant plugin

Maven comes with a handy plugin to generate an “Ant” build file from Maven pom.xml automatically.

Please visit the Maven’s Ant plugin official page. – http://maven.apache.org/plugins/maven-ant-plugin/index.html

2. mvn ant:ant

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
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-ant-plugin/2.1/maven-ant-plugin-2.1.pom
8K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-ant-plugin/2.1/maven-ant-plugin-2.1.jar
35K downloaded
[INFO] ------------------------------------------------------------------------
[INFO] Building abc
[INFO]    task-segment: [ant:ant]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.pom
2K downloaded
Downloading: http://repo1.maven.org/maven2/xalan/xalan/2.7.0/xalan-2.7.0.pom
491b downloaded
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
205K 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] ------------------------------------------------------------------------

3. Done

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

Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world\'s largest enterprise software company.
Publisher : Oracle Corporation