14

We have been slowly replacing batch command files (windows .bat) which were simply jarring up the classes compiled in the developers IDE, with more comprehensive Ant builds (i.e. get from CVS, clean compile, jar, archive, email, etc.)

I've spent a lot of time learning (and debugging issues) with Ant, so I'm most comfortable using it for these tasks. But I wonder if Ant is still in as wide usage as it was when I first started learning, or whether "the world has moved on" to something newer (and maybe slicker). (I've started to see more Maven build stuff distributed, which I've never used, for example.)

The practical import of this question, is whether I push new developers to learn Ant, or whether they should be learning something else for builds?

I'm never too on top of the trends, so it would be great to hear from other Java developers what they think is the best build tool, and what they think new developers should be learning.

9
  • Read all the answers below and they were all great! Thanks for the insights into what improvements Maven offers over Ant. I will be looking into Maven. Commented Nov 17, 2011 at 18:28
  • It is very few projects that are simple enough not to require tons of scripting for ant. Maven handles a lot of these things in a standard way.
    – user1249
    Commented Nov 17, 2011 at 23:19
  • Ant is basically a shell script in XML (and using Ant commands instead of shell commands). Commented Jun 30, 2016 at 4:10
  • Ant is an incredible waste of time. Even when maven was terrible it was a smarter choice. Ant has no way of being integrated into an IDE and Java projects are a huge mess of files - you spend 30% of your time just jumping from file to file.
    – bryan hunt
    Commented Sep 13, 2017 at 20:21
  • @bryanhunt: we ended up using Maven for all new projects. However, I haven't found a nice way for Maven to create a deployment package for Java apps. (It's fine for copying dependencies, uploading jar.) Most of the posts I read that answer how to do it, say to use the Ant plugin. So I find I am using Ant to groom the final output from Maven. And it seems way easier to do it in Ant than to use the Maven Assembly plugin. Commented Sep 13, 2017 at 21:02

5 Answers 5

24

I agree with others here that Maven seems to have taken over most significant projects that I've looked at.

While Ant is highly flexible, the build file is not standardized, so when you move to a new project or company, the targets are named differently, the file is structured differently, the inter-target dependencies may or may not be established, etc.

With Maven, you also get the benefit of not having to carry binary dependencies (I'm talking about jars) around in your SCM system. Lots of other great Java tools know how to read a Maven POM file (the benefit of standardization), so tools like IDEs can set up a Maven project very quickly, and build tools like Jenkins can easily execute Maven builds.

1
  • 13
    I should also add that using Maven makes our projects IDE-agnostic, and if you've ever been in a shop that had IDE wars, you can appreciate eliminating this religious battle!
    – RonU
    Commented Nov 17, 2011 at 16:35
11

I've been working with Ant and with Maven. In my experience, Maven has a very strong edge over Ant.

  • All the projects I've seen last 2 or 3 years seem to be using maven. About 3 years ago this made me wonder because maven versions used then (2.0.something) seemed to be quite unreliable and buggy. At some point though (2.1 or 2.2 I don't recall) maven became reliable and after some time spent with it I have changed my mind to opposite. Now, I'd rather be surprised seeing someone who prefers ant over maven.

On a less positive note about maven, my experience with its documentation was not so great so far. I think I've seen a product with documentation worse than that of maven but I can't remember which one (some ancient CSV library iirc).

4
  • 2
    Dunno, I found the Maven Reference quite decent. It is not perfect, and there are dark undocumented corners indeed, but still IMHO it is significantly better than the average. Commented Nov 17, 2011 at 16:13
  • @PéterTörök right Maven Reference is my first aid too. Somehow though most of the stuff that worries me happens to end in these dark undocumented corners. To be precise I find these corners more "dark" than "undocumented" - I mean I feel the knowledge is there but I fail to decipher it. I dunno maybe I am unlucky. Or maybe dumb. Or maybe Maven guys just lack a decent tech writer in their gang
    – gnat
    Commented Nov 17, 2011 at 16:36
  • 1
    Why, have you ever seen an open source project which had a decent tech writer? ;-) Commented Nov 17, 2011 at 17:20
  • @PéterTörök so true! :) The luxury of popular OSS projects is that there are a lot of expert guys around who "replace" doc writer. To me that was the case with Maven - there always have been some guru around whom I could ask about tricky things
    – gnat
    Commented Nov 17, 2011 at 17:56
3

We've been using Maven for several years. It supports Ant scripting (just like Ant supports BeanShell), so your Ant knowledge may still be useful. Maven is much more powerful, but it has some additional infrastructure requirements (you'll want an Artifactory or Nexus server to host your builds if you share components among multiple projects). It's also quite different from Ant, so you can't leverage a lot of your existing knowledge.

1

I think Ant on its own is dead in the water; having to specify all of your classpath dependencies manually (depending on your setup) is far too manual and far to error prone. If Ant is used alongside a dependency management tool, such as Ivy, then it retains it's power and removes the need to manually manage your dependencies.

The other problem with Ant when compared to Maven is the lack of standardization, which has been mentioned in other answers. When moving from project to project or job to job, one of the most annoying things I find is having to learn the new standard for different Ant files. Maven's aim of convention over configuration means that two different projects will have very similar structure, making transition between them much easier than with Ant.

As for whether Ant is still mainstream or not, it will depend on the development environment you are working in. If the project is in a small company or a start-up, I would imagine Maven would be the natural choice and time can be taken to invest in the infrastructure, such as an Artifactory. However, large companies will have invested many years and lots of money into their Ant infrastructure (configurations, global build files etc) which will mean they will be less keen on moving away from a technology in which they have invested so much money.

0

Maven has been on the rise for many years, and now I need to learn it. Things will always be changing, and to know that Ant is losing its position is not a bad thing.

Maven may only be the up and comer for a short time, but if it makes our job easier, then it is worth investing the time to learn.

Not the answer you're looking for? Browse other questions tagged or ask your own question.