Mavenize ANT Project

How to mavenize an existing ANT based project


Due to dependency management, artifact versioning and project comprehension I came across a project where I need to convert an existing ANT based large project to Maven (I would like to say Mavenization).

Here I don’t want to become an advocate of Maven but sharing my experience to move an ANT project to Maven.

**Please Note before going further you must go through the short Maven tutorial provided by Apache “Maven in 5 Minutes”. (Google Maven in 5 Minutes, you will find the link)

Existing ANT Based project

This single but big project generates multiple artifacts including generic APIs, server side Application and clients like Applets and JNLP based swing clients.

ANT was being used to compile, generate, test and build the project. The build.xml file itself is big enough to take considerable time to decompose into smaller actions.


1)      Make sure you got the latest copy

Get the latest version from CVS/SVN from existing working branch of the project into a separate directory.

2)      Decompose

Plan and document decomposition of the project into three different types of components:

a)      Identify reusable generic APIs/modules that can be shared among different modules. For e.g. like custom utilities, Core API etc.

b)      Server side business or service layers that might depend or inherit on the modules identified above. E.g. EJBs, Spring Ioc classes

c)       Clients like Applets, Swings or JSPs or classes built using Spring MVC or Struts framework.

Try decomposing (refactor) the project so that no cyclic dependency is left and each module producing one artifact. Your module may produce two artifacts but then you would need Maven assembly plug-in to create multiple artifacts. In my case I have single module for producing two different types of client Applets.

3)      Maven Standard Directory Layout

Generate the maven standard directory layout by using mvn archetype:generate command.


mvn archetype:generate -DgroupId=<groupId> -DartifactId=<artifactId>
-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false



4)      Create Project Object Models (POM)

a)      Create Parent POM file, add external dependencies (3rd party jars) that are shared among all the modules to corporate repository like log4j, apache commons etc.

b)      Create child POM files for each module and copy the source files into the new directory layouts accordingly

c)       Write module inter-dependencies in child POM file

d)      Write external 3rd party dependencies (make sure shared 3rd party dependencies should go in the Parent POM file)

5)      Compile and test

Compile each module one by one starting from the module that has no inter-module dependency. Make sure you don’t have cyclic dependency between the modules.

6)      Build Project

Use Assembly plug-in to generate multiple artifacts for a single module