Maven ant plugin – Generate build.xml from pom.xml

Suppose you had created and maintained your project from maven for long time, but now you have instructions to move it to ant build environment. Well, it does not look easy, but it really is very much.

All you need to use if maven ant plugin which is specifically only for this purpose.

$ mvn ant:ant

Lets see a detailed example to generate ant build file from maven pom file using maven ant plugin.

1. Create sample maven project

$ mvn archetype:generate 
			-DgroupId=com.howtodoinjava 
			-DartifactId=antBuildScriptDemo
			-DarchetypeArtifactId=maven-archetype-quickstart 
			-DinteractiveMode=false

2. Generate ant script from pom.xml

$ cd antBuildScriptDemo
$ mvn ant:ant

3. Demo to generate build.xml from pom.xml

Above command will generate 3 files in project root folder.

  1. build.xml
  2. maven-build.properies
  3. maven-build.xml

To run the above generated ant file, install ant in your system and execute the build.xml file like this:

ant build.xml

Happy Learning !!

Reference: http://maven.apache.org/plugins/maven-ant-plugin/index.html

Was this post helpful?

Join 7000+ Fellow Programmers

Subscribe to get new post notifications, industry updates, best practices, and much more. Directly into your inbox, for free.

4 thoughts on “Maven ant plugin – Generate build.xml from pom.xml”

  1. hi
    im using ‘tomcat7-maven-plugin ‘ to deploy my web project.but I have to redeploy the whole project when I even change a static resource(html /css /js).Is there way to do that(only copy static resources) to tomcat using a maven plugin?

    Reply

Leave a Comment

HowToDoInJava

A blog about Java and its related technologies, the best practices, algorithms, interview questions, scripting languages, and Python.