Sunday, November 2, 2014

Maven vs Ant : Decision is not Boolean.

At some point of time in a developer's life, you have to make decision on what to do use :  Maven or Ant for your project build.
My project was using Maven when i joined it, so i wanted to know on what is the thing called Ant doing in market. And why our leads and managers choose Maven over Ant for project.

It is a big debate but lets take some simple points that we can, so that we know which one to use in which condition.

Lets have a take on Maven first.
So Maven is project management framework which uses project object model to build and make a jar.
Maven is like a complete flavored milk ready for kids who love flavored milk and don't like to take the pain of adding flavors and mixing all the things.

More points Maven :

1) With Maven you will have some rules and conventions to follow , so that everything falls in place and things are build on the basis of that.
So you have to place your source code in a particular folder the class file will go to a particular folder.
You can  specify the folder where your JAR/WAR will go and store after the build.

2) It will run the test case for you automatically when ever you decide and just write a single command. All you have to do is write down the test cases and place them in a particular folder
and maven will run it for you. (Remember : MVN TEST)

3) Maven is declarative with a life cycle which Maven follows. So its a framework and it will have a life cycle always. So you can configure it at some point in life cycle according to your need s
or not then it will run the default process for you.

4) It is a project management tool which does help in building your project also.

5) You can create many small projects and then build them together in a  single war using maven and all dependencies all handled and its easy to understand for a new developer
and not much of single script to look at and fix the  issue.

6) Last thing is where Ant wins is If you have a complex build and need to configure lots of things in your project , then Ant wins here.

Now our old guy Ant :
Ant is a build tool where you have to write the script in xml to define how to build your project.
So its like you have to go to market buy milk and your favorite flavor and then mix them well at home according to your need and enjoy while watching Two And Half Men.

More Points on Ant :


1) 
You can define your own rules here , there are no specific guidelines here and its very customizable.

2) For running the test case , you will have to sweat out your brain. But you will understand lots of basic things here.

3) Ant is procedural. you need to define all the things where to place class files and where to place your JAR and how to do it , when to do it. It has no life cycle.

4) Its a build tool. and in case of large projects , it might turn a nightmare. But if you understand some basic things you can pretty much have it up.

5) Ant has a  customizable procedural build which gives you the freedom to do things in your own way. You feel much confident on how your build process is working while using Ant.
Because you pretty much know what are the basic concept i defined in XML which is doing the magic.

6) Last thing which i already explained for tedious work and better control over your build process, go for Ant.

But you can mix both also Maven plugin can implement Ant scripts within the maven project life cycle and vice versa.
And there is new guy Gradle in the town which we discuss in my next post.