How to generate ant build file from maven

Suppose you had created and maintained your project from maven from 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’s ant plugin which is specifically only for this purpose.

Lets see an example:

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) Above command will generate following 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

Lokesh

I have 7 Years of rich experience in java technology. This has only increased my hunger to learn more. In this blog, i will be writing on different topics occasionally, and would love to engage in some meaningful serious discussions with you folks.

You may also like...

3 Responses

  1. Suresh says:

    Hi Lokesh,

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

  2. vinay says:

    thanks a lot you save my life

Note:- In comment box, please put your code inside [java] ... [/java] OR [xml] ... [/xml] tags otherwise it may not appear/post as intended.


Want to ask any question? Or suggest anything?