Content received from: http://JavaFAQ.nu/java-article1168.html
Maven vs Ant or Ant vs Maven? Saturday, October 27, 2007 (09:54:27)
Posted by jalex
Maven vs Ant.
This article is not about religious war between two groups of developers, it is about what is real difference between two tools and why in one case you choose Ant and in another Maven. It help you if you f you in a hurry to make a choice between two Java build tools. Very easy to understand overview over Maven and Ant build concept.
We usually prefer one tool over another because we want make developers happy and:
- Develop faster
- Concentrate on real work
- Generate all related document easy
We also prefer one tool over another to keep our bosses happy, which means:
- Reduce development costs
- Reduce time to market
- Frequent status reports, which can be easily presented to higher boss
Historically Ant is much older tool and it was deigned to have some Java-based build tool. Something similar to Make which most of C++ developers use. Those who worked with Make probably know that is extremely powerful tool which can do whatever developer wants.
Ant is different. Instead of a model where it is extended with shell-based commands, Ant is extended using Java classes. Instead of writing shell commands, the configuration files are XML-based, The power of Ant in practice results that you have to setup build process yourself. Each project can have different build process. New team members have to study this version of build which is probably they used to have in another project.
Maven (Maven)on another hand wants a standard way to build the projects, a clear definition of what the project consisted of, an easy way to publish project information and a way to share JARs across several projects.
Maven does encourage best practices and some people can prefer Ant. Maven is less flexible than Ant and you have to be agree with making of some compromises.
Maven is not the next generation Ant!
Ant and Maven are different. Maven is not just a building tool, it provide an organization and a structure layer. All you do in ant can be done in Maven because you can call ant target.
The main advantage to migrate to Maven are : standardization of how to handle a project, dependencies are clearly defined, the concept of artifacts that can be shared to other projects, documentation and reports, remote and local repository concepts.
Maven will help you with:
- Making the build process easy and provide uniform build environment
- Generate quality project information
Comparison table for major advantages/disadvantages - Maven vs Ant.
| Maven |
Ant |
| Description of project |
Development of a build script per project |
| Invocation of defined goals (targets) |
Invocation of project specific targets |
| Project knowledge |
"Just" the build process |
| build lifecycle, standard project layout |
too complex scripts |
| reusable plugins, repositories |
scripts are not reusable |
| moving fast forward |
development are slowed down |
The good thing with Maven that it is extremely flexible, because it consists of core and numerous plugins that are accessible in online repositories. Relations between different projects and subprojects are based on a single source of information POM (xml) file - Project object Model. One POM points to another POMs which can have flat or hierarchical structure.
A project produces an artifact - jar, ear, war... The next features are good with Maven:
- Dependencies are downloaded automatically
- Standardized, very consistent layout
- Standardized, very consistent naming
- Code coverage
- Extensive reports
- Maven easily works with JUnit tests
|