Adam Bien's Weblog
Maven vs. Ant
Maven vs. Ant is one of the semi-religious topics (like IntelliJ vs. Eclipse, SWT vs. Swing or Spring vs. EJB). Dependent on you specifics needs, both build tools may be interesting for you. Ant is just a framework, or a build-DSL which cannot be used out of the box. You have to create your build-script from existing Ant-tasks. The Ant tasks do not presrcibe any conventions or configuration - the definition of project layout is your responsibility. You have full control of whatever you are doing - what can become a problem in bigger projects.
Maven can be understood as "Ant With Convention Over Configuration". In fact if you rely on conventions like the "Standard Directory Layout", you can start without any fraction or configuration with maven. You will only need a good internet connection for the first build :-).
As with every Convention Over Configuration framework, you will have to understand the conventions to be able to work efficiently. In case the conventions do not work in your case, you will have to overwrite them - and the complexity of this task is really hard to estimate.
The real strength of maven is the dependency management. You only have to declare the dependencies - maven will download them, setup the classpath for you, and even deploy the dependencies with your application if required. Maven manages not only the direct dependencies for you - but even the dependencies of the dependecies (transitive dependencies). This is the real strength of maven. Ant doesn't have such capabilities out-of-the-box (except ivy) and it will take a considerable amount of work to emulate Maven's dependency management with Ant.
I use maven and ant in my projects, the choice is dependent on the specific needs. Maven is great if:
- You are working with many "creative" developers. It will be hard to establish a defined project structure etc. without tool support.
- The developers are religious about their IDE - and are using IntelliJ, Netbeans and Eclipse at the same time.
- You are building a product-like application. You will have to manage different versions and branches with their dependencies.
- You project consists of several teams which work on dependent modules. This modules have to be composed to the application regularly.
- You plan to use checkstyle, pmd, generate a project website etc. Its easy with maven.
On the other hand I would choose ant for:
- "Situational Software" which has to be developed quickly (few weeks / months).
- Projects with external dependencies which are working with "cutting edge" libraries. There is no need for finer grained dependency management.
- Netbeans Project :-). They come already with ant-script which even works perfectly with hudson. Just check everything into svn, and let hudson check it out...
- Legacy projects which do not fit the maven conventions very well. Violating maven conventions may become a hassle.
- Projects without explicit requirements for modularization. The deployable output will consist of only few archives.
Java EE 7 + HTML 5 Workshops, 7th Edition: March 24th-28th, 2014, Airport Munich Tweet Follow @AdamBien