The ubiquity and utility of Ant as a build tool for Java projects is virtually unsurpassed. Even Maven, the new, upstart utility in the build arena, owes much of its power to lessons learned from Ant. This article introduces Groovy’s builder utility, which makes it especially easy to combine Groovy with Ant and Maven for more expressive and controllable builds.
Why is it that after two decades, POSIX Make is still the only widely viable build system that is language independent?
Ant requires the JRE, which isn’t always available. Also, when I saw people adopting Ant, it felt more like a bandwagon rather than “Hey, this really _does_ work better.” People cared more about the fashionable XML than anything else, which isn’t the proper way to judge a major part of the development process.
Tell me about it. Make is a joke. The autotools are a clusterf*ck that everybody hates. And Unix is supposed to be a great developer’s platform.
Yeah, and I agree with your comment about people using XML just because it’s xML.
“The autotools are a clusterf*ck that everybody hates.”
Yeah, when they work they work, but when they fail you might as well go fishing. The autotools are most definitely not the shining star of the GNU effort, but, unfortunately, that’s a bandwagon even bigger than Ant.
You’re missing the point.
Ant is ideally suited to compiling Java because of it’s extensive support for things that make compiling and processing Java easy. So the JRE requirement is mute. It’s actually a benefit since the JRE doesn’t have to be restarted each time you compile a file, so you can compile faster than with make or any non-Java build tool.
Ant is probably the best tool for cross-platform compiling of Java/Groovy/Jython code, but there are better tools for compiling C or C++. The age old rule applies, use the right tool for the right job.
Make can invoke javac in the same way that Ant does, nullifying any speed benefit of Ant. This is possible, because javac does some of the timestamp checking internally that would otherwise be done by Make rules. The knowledge required to do this in Make is held by anyone with UNIX experience (basic shell scripting), and that knowledge is applicable to many things beyond Make making it much more useful than spending the time learning Ant. Actually, if more Java programmers spent a few moments to learn basic scripting skills, they could save days of work not re-inventing the wheel over and over (e.g., text processing).
When someone decides to make a better Make…they make it language specific. Bleh. Pretty much every programming language follows a model of multiple files composing a larger program with minor variations. The basic dependency problems to solve are similar across languages. A better Ant would be written in C (the most portable language), would be pluggable for language support, and would solve the problems Ant claims to solve but for a broader audience.
Make can invoke javac in the same way that Ant does, nullifying any speed benefit of Ant. This is possible, because javac does some of the timestamp checking internally that would otherwise be done by Make rules. The knowledge required to do this in Make is held by anyone with UNIX experience (basic shell scripting), and that knowledge is applicable to many things beyond Make making it much more useful than spending the time learning Ant.
Save that I’ve yet to see a decent Make script that handles Java efficiently. Not saying they don’t exist, I’ve just not yet seen one on any large project. I’ve see small, crappy, slow ones on small projects, but not large projects.
And the ones that I have seen are based upon the classic “C” model of make, which is not only slow for Java (invoking javac for each file), it leaves the dependency checking up to the script maker, and not the compiler.
Finally, the “language specific” nature of Ant is probably it’s KEY benefit.
Make is but one gear in the whole machine that is Unix. Take Make in isolation, i.e. without the shell, without the vast array of Unix utilities, and it’s pretty well worthless. With Ant, you take the JDK (which is needed for Java programming anyway) and Ant, and you pretty much have it all.
This allows Ant to work identically anyplace that Java works (like Unix, Windows, AS/400’s, etc.) Places where Make make won’t work “out of the box”.
So, particularly in a Java shop, that makes Ant even more inviting. Now I don’t have to write my scripts to be “cygwin aware”, or write CMD files for Windows and .SH files for the UNIX deployment boxes. I don’t have to worry about pathname issues (Ant handles all that for me), so the same Ant script runs on everything we have.
Finally, you have the IDE folks now using Ant (NetBeans is now Ant based, for example), you have folks like BEA or Tomcat shipping tasks that work well in Ant for managing their servers, building their applications, etc.
Yeah, all of this could have been done with shell scripts, but by using Ant we gain portability, lessen dependency, and improve performance overall, yet we end up with a reasonably simple model and a build system that is easy to extend.
If you really want fast compile speed, you use Jikes anyway. Sun javac is very slow.
But they are a lot of advantage in using XML:
*First the syntax is easy to learn
*It’s possible to verify if the syntax of a written file is correct.
*They are modes for it for emacs, eclipse, are other editors. so every one can relly on his favorite editor.
*Finally, its possible to use a lot of tools on it (like xslt). They is for example a software that is called antDoc, that uses xslt to make HTML-Documentation from ant build files . And why is this necessary ? Because not all build files are only 100 lines big …
HelloWorld82
Tell me about it. Make is a joke. The autotools are a clusterf*ck that everybody hates. And Unix is supposed to be a great developer’s platform.
But autotools are not your only choice. There are some alternatives such as the Pre Make Kit project (http://pmk.sf.net)
The Perforce folks have a make replacement called “jam” that’s supposedly awesome. Written in C for portability, very flexible, etc.
Of course, nobody uses it because it’s not make.
I don’t think I’ve heard of anyone using Ant because it’s “better”, just because it’s Java.
– chrish
Some people here are missing the point, besides the fact that ANT runs on the JVM which not really is a plus, it has several big advantages over make.
Better javac handling with auto dependency check etc…, saner syntax, but the biggest plus is that it basically eliminates almost any dependency into a system tool or command line tool.
The main problem make has is that it basically roots most of its tasks into command line tools which can cause problems on various platforms which dont have the tools neeeded. With ant in 99.999% of all cases the tool already is covered.