HowToDoInJava

  • Java 8
  • Regex
  • Concurrency
  • Best Practices
  • Spring Boot
  • JUnit5
  • Interview Questions

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

By Lokesh Gupta | Filed Under: Maven

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

About Lokesh Gupta

Founded HowToDoInJava.com in late 2012. I love computers, programming and solving problems everyday. A family guy with fun loving nature. You can find me on Facebook, Twitter and Google Plus.

Feedback, Discussion and Comments

  1. bintu

    December 1, 2014

    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
  2. Suresh

    March 18, 2014

    Hi Lokesh,

    Thanks for post. Can i see post regarding ANT tutorial so it ll helpful.

    Reply
  3. vinay

    January 14, 2014

    thanks a lot you save my life

    Reply
    • Lokesh Gupta

      January 14, 2014

      Welcome

      Reply

Ask Questions & Share Feedback Cancel reply

Your email address will not be published. Required fields are marked *

*Want to Post Code Snippets or XML content? Please use [java] ... [/java] tags otherwise code may not appear partially or even fully. e.g.
[java] 
public static void main (String[] args) {
...
}
[/java]

Search Tutorials

  • Email
  • Facebook
  • RSS
  • Twitter

Maven Tutorial

  • Maven – Installation
  • Maven – Settings
  • Maven – Dependency Mgmt
  • Maven – Dependency Scopes
  • Maven – POM
  • Maven – Parent POM
  • Maven – Repositories
  • Maven – Local Repo Path
  • Maven – M2_REPO
  • Maven – Network Proxy
  • Maven – Enforce Java Versions
  • Maven – Simple Java Project
  • Maven – Web Project
  • Maven – Multi-module Project 1
  • Maven – Multi-module Project 2
  • Maven – Java Source Folders
  • Maven – BOM [Bill Of Materials]
  • Maven – Import Remote Catalogs
  • Maven – Create Custom Archetype
  • Maven – Compiler Level Mismatch
  • Maven – Ant Build
  • Maven – IntelliJ
  • Maven – JSTL Support
  • Maven – Tomcat Plugin
  • Maven – Uber Jar for Spring Boot
  • Maven – Shade Plugin

Popular Tutorials

  • Java 8 Tutorial
  • Core Java Tutorial
  • Java Collections
  • Java Concurrency
  • Spring Boot Tutorial
  • Spring AOP Tutorial
  • Spring MVC Tutorial
  • Spring Security Tutorial
  • Hibernate Tutorial
  • Jersey Tutorial
  • Maven Tutorial
  • Log4j Tutorial
  • Regex Tutorial

Meta Links

  • Advertise
  • Contact Us
  • Privacy policy
  • About Me

Copyright © 2016 · HowToDoInjava.com · All Rights Reserved. | Sitemap