• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ant vs Maven newbie question

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Sorry for the newbie question.
I don't know neither Ant nor Maven. My question is which of the two is better to spend time to learn and why?

Thanks!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't really know how to answer that--both are still used frequently, although some folks are switching to things like Gradle, Gant, Rant, Rake, etc.

Maven does more "out of the box". When it breaks, it breaks *spectacularly*. If you need to do something *not* in the Maven way, it can be a real pain. Real as in literal-my-brain-hurts. Ant requires more manual labor, but with things like Ivy (dependency management) can do "all" the things Maven does, but only with effort.

So it's up to you.
 
Jim Akmer
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also if I use an IDE, why would I need to learn a build tool?
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jim Akmer wrote:Also if I use an IDE, why would I need to learn a build tool?


An IDE is only for development - when you then need to deploy/distrubute whatever you have done - then you need to do some packaging, and it is here that ANT/Maven will/can be used.

If you need to e.g. generate Java Client Source Code from a web service (WSDL), then you can use Ant/Maven or a command line to do it - but to be able to re-use the command used more easily, it would be a good idea to use Ant or Maven where you then have it documented in their build scripts (some IDE's can also do this kind of code generation, but they normally use some kind of build tool behind the scene).
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jim Akmer wrote:Also if I use an IDE, why would I need to learn a build tool?



There are a number of reasons.

1. While this isn't as big a problem in Java as on other platforms, changes in IDE versions can result in problems building applications down the road. A certain very large offender that I won't name was pushing it to the point where I think now some of my older apps would actually require re-installing an obsolete version of their OS in order to install an obsolete version of their IDE just to make an emergency 1-line code change. The batch builders such as Ant and Maven are less version-sensitive when it comes to backwards compatibility.

2. I worked in a shop where we were supposed to be sharing components. For the most part, we couldn't, because to build the components, you have to have precisely duplicated the IDE setup that the original author used, including his/her departmental standards and services. Which at best, was a major pain to set up, and at worst, conflicted with our own departmental IDE configurations.

3. I've also worked in environments where you submitted only source code for production. The actual binaries were produced elsewhere, thus ensuring both buildability and eliminating any hidden binary "back doors". However, the build process was done in batch on a server machine that had no GUI desktop, and therefore no IDE.

4. Very complex projects often require extra build steps such as rmic, xdoclet and so forth. Trying to setup an IDE to include all this is no trivial task. I generally don't even try, since it's easier to run Maven or Ant.

5. A particular virtue of Maven is that (like it or not), it enforces a standard project structure. Essentially, if you've seen one Maven project, you've seen them all. I don't claim I totally love its standard organization, nor for that matter, a number of other things about Maven. However, I know that if someone dumps a project on me, I won't have to waste time finding where everything is.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Plus a build file can be used by a CI (Continuous Integration) server. Plus you can customize the build at build time (similar to the point about additional tasks) like building only certain components, etc. without having to have an explicit target (Ant target, I mean) or change the build configuration--just by defining a property on the command line. Plus you can build on the command line more easily than with an IDE's embedded build process for quick changes without having to slog through IDE startup.

For small, personal, one-off projects, it may not matter. For real work, it does.
 
Jim Akmer
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for the great answers!
One last thing though. Since I do not know neither Ant nor Maven, which will give me more of an advantage (more frequent wanted from companies, more frequently used by frameworks etc) to spend time learning?Also if learn one of these, is the learning of the other (if needed) trivial (the concepts are the same?) or it is like starting all over?

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea which is used more. I have yet to work for a company that uses Maven, but I know of many companies that do.

It's like starting all over.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should learn a little about Maven even if you go with Ant. Maven very strongly recommends (i.e. dictates) a very specific directory structure and while I have a few nits with it, I always use that structure, or a slight modification of if, with any Ant-based projects that I have.

Be aware that Maven is a black-box. It is a whiz regarding build/test/packaging because that knowledge is built in. To get it to do anything other than what it was written to do (such as generate two artifacts for a single project) is often an exercise in frustration. Ant, on the other hand, is more of a scripting language - it gives you a lot of primitives that you can combine in interesting ways to do a variety of things, with build/test/packaging being only some of those things.

You should definitely read a book. Ant in Action is a must-have for Ant - I have the author's prior version of that book and found it indispensable. For maven, there are two good books online: Better Builds With Maven and Maven the Definitive Guide.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic