Java Development with Ant 171
Java Development with Ant | |
author | Eric Hatcher, Steve Loughran |
pages | 634 |
publisher | Manning |
rating | 8.5 |
reviewer | Spencer Marks |
ISBN | 1930110588 |
summary | How to use Ant to meet all (or most of) your poject's software configuration needs |
Pros:
- Excellent coverage of optional Ant tasks
- Good division of beginner, intermediate and advanced content
- Thorough discussion of how to use Ant to solve a variety of software configuration management situations
- Shows how to use Ant for tasks outside of typical configuration management roles such as the automated code generation of EJB and Application Server deployment descriptors
- Shows how Ant helps with a variety of software development methodologies including XP's suggested best practices of continual integration and JUnit testing
- Catalogs IDEs that integrate well with Ant including my personal favorite, Intellij's IDEA development environment
Cons:
- Some of the examples could have benefited from more detail. For example, the section on the PropertyFile task could have shown how to solve the problem of platform specific path separators in Java property files.
- At the time of this review, the book's accompanying website was a bit meager. For example, a comprehensive list of Ant on-line resources would have been helpful.
What the book offers
I consider myself an intermediate Ant user and when books on Ant first appeared I thought they would add little to the excellent free documentation and examples readily available. With its clean, straight forward syntax and structure, Ant has a low of cost of entry, and being rooted in Java and XML it is extremely flexible and extensible. I found Ant refreshingly easy to use as part of a configuration management system that included continual integration and a unit testing strategy. It was much better suited for Java development than the tool I previously used which was make. So when I agreed to do this review, I was skeptical that I would find the book useful. However, the book proved to be rich in valuable information that is well organized and clearly presented. Java Development with Ant, written by Erik Hatcher and Steve Loughran who are both committers to the Apache Ant project, is a great resource for anyone wishing to learn how to integrate Ant into his personal set of best practices for software configuration management solutions.
Coming to the book as a long time Ant user, I was glad to see that it offered material appropriate for others than just those approaching Ant for the first time. The book is divided into three sections each of which could probably find a niche as useful (and thinner) separate book: Learning Ant, Apply Ant, and Extending Ant. Only the first section of the book is devoted to first-time users, or those Learning Ant. The reminder of the book is about Ant in action. It covers an interesting variety of third-party Ant tasks, various ways of applying Ant to software development projects, and an in-depth section on how to extend Ant writing your own Java classes.
After a short but helpful introduction to the general topic of software configuration management, the first section, Learning Ant, launches into a thorough explanation of Ant's fundamental concepts and operation. JUnit test integration is treated as part of of the basic operation of Ant, which I was happy to see because unit testing should be a fundamental part of any software configuration management process.
Despite having used Ant on a number of projects since the summer 2000, at no point have I had to become truly expert with it in order to solve the wide range of software configuration problems I encountered. This is because Ant is easy to use. Typically, I figure out what I want the software configuration management to do, and then look for Ant examples that I can easily tweak to get the job done. I think it is a great credit to the Ant and its designers that I can do this successfully. Even though I've had this success with Ant, the introductory material filled in some of the gaps I had in my understanding of Ant's operation. For example, I was introduced to the PropertyFile taskdef which up until then had escaped my notice but which solved a problem for which I previously had a less elegant solution.
The most interesting part of the book was the second section that talked about a variety of Ant add on programs (called taskdefs) like Middlegen (an EJB descriptor tool) and XDoclet. XDoclet had been on the periphery of my radar for a while now, so I welcomed the book's thorough discussion of it in both a general and Ant specific sense. In addition there are helpful chapters devoted to using Ant as an aide to production deployment, web site generation including the compilation of JSP pages and the automatic generation of EJB descriptors. There are also chapters on working with Web Services using SOAP and a section on how Ant can be used as part of a continuous integration process complete with email notification. There is even a section on using Ant for Java projects that have a native code component. (Ant can be used to compile native code and the book shows how it can be helpful in dealing with the complexities surrounding JNI.) The book works well as a reference text. There's no need to read it from cover to cover in order for it to be extremely helpful.
The third part of the book also looks interesting, but it is intended for a more hardcore audience than myself. I've been fortunate to find ready made solutions for all the configuration management services I wanted to provide my clients. So, learning how to extend Ant has never been an issue. Every time I think I might have to develop my own answer, I find that someone else has already beaten me to it. Such is the nature of successful Open Source projects. However, I am glad this section exists, because I am sure at some point I will use it myself or refer a student or client to it.
The book even has some material on using Ant outside of the context of Java. Not having much experience with these technologies, I didn't pay close attention to these sections. (I am sure I'll be amused when I encounter my first .NET project that is using Ant for its configuration management solution).
In closing, if you are more than casually interested in software configuration management for Java projects then I recommend this book with enthusiasm. Beginners will be up and running with Ant in short order, while the book contains many interesting and useful nuggets for more experienced Ant users.
Ant on the web
- The Ant Project -- be sure to see their resources section.
- Ant FAQ at jguru.com (moderated by the book's co-author: Erik Hatcher)
- Ant forum at jguru (moderated by the book's co-author: Erik Hatcher)
- JUnit: A regression testing framework written by Erich Gamma and Kent Beck. It is used to implement unit tests in Java.
- CheckStyle: A development tool to help programmers write Java code that adheres to a coding standard.
- Middlegen:A general-purpose database-driven code generation engine.
- XDoclet: An extended Javadoc Doclet engine. It's a generic Java tool that lets you create custom Javadoc @tags and based on those @tags generate source code or other files (such as xml-ish deployment descriptors) using a template engine it provides.
- Intellij's IDEA "Develop with Pleasure" with this award winning Java IDE featuring full Ant integration that Marin Flower says: has succeeded in really moving forward the state of the art...
- The NetBeans and Eclipse Open Source IDEs also integrate nicely with Ant.
Use campusi.com (Score:1, Interesting)
and FP?
Well (Score:5, Funny)
It's good that there's a book on how to get them to do what you want.
Re:Well (Score:1)
Ant is... (Score:5, Informative)
Also, it has become somewhat of the defacto standard in open source Java development.
Re:Ant is... (Score:4, Insightful)
javac -d classes `find src \*.java -print`
Re:Ant is... (Score:2)
Re:Ant is... (Score:2)
Re:Ant is... (Score:3, Informative)
"In order to find out which files should be compiled, Ant compares the timestamps of the source files to those of the resulting
I'm pretty sure ant is smart enough to do "conditional compilation", or rather the compilation of only changed sources, since I think that's what the original poster meant.
Re:Ant is... (Score:3, Informative)
But it does not (by default) do full dependency checking to force rebuild a file when a class it imports changes. The Task does that, (something we cover in chapter, 10 BTW). Even that task, which looks through the
There is a lot to be said for clean builds using jikes, as that is reliable and fast.
-Steve Loughran, co-author Java Development with Ant
Re:Ant is... (Score:2)
Re:Ant is... (Score:1)
Re:Ant is... (Score:2)
It really isn't an equivalent replacement. Although it is potentially more widely deployable than make, make is still much more powerful, because the
Also, make is much more appropriate for offices that do development using more than one programming language (C, C++, Java, Lisp, etc.). It seems Ant is really a tool for Java developers (even though it is possible to kludge Ant's XML files for non-Java projects, I think it would get pretty ugly pretty fast).
Re:Ant is... (Score:1)
I do use an IDE like Forte [netbeans.org] and in fact it has *great* Ant integration and you can even install the Ant documentation so it's available from within the IDE.
As a matter of fact, all the IDEs I've tried recently for Java do in fact make efforts to integrate Ant. (Eclipse, IntelliJ, even ... JDeveloper)
Ant sucks (Score:3, Interesting)
Still, I have high hopes for the next big version of Ant where they plan to fix a lot of these problems.
Re:Ant sucks (Score:3, Insightful)
Ant sucks. But its the least sucky option. The syntax is very inconsistent, and there's a lot of things you can't do easily (i.e. control flow). But for 90% of a build process, Ant will do what you need out of the box.
First you say "it sucks" then you say it works 90% of the time. Those seem contradictory (to me anyway.) What areas have you found Ant to be lacking in that lead you to believe it sucks?
Re:Ant sucks (Score:2)
Ant is definetely a case of 'Worse Is Better', as opposed to being 'The Right Thing'.
Re:Ant sucks (Score:2)
Re:Ant sucks (Score:2)
Re:Ant sucks (Score:3, Insightful)
Ant is for wimps (Score:2, Troll)
I've always used makefiles for my Java development and it works very, very well. Make is a proven product, has a well-defined, well-documented syntax and for the most part, is very easy to read (while Ant's XML mishmash is a mess).
Re:Ant is for wimps (Score:5, Informative)
--------
Why another build tool when there is already make, gnumake, nmake, jam, and others? Because all those tools have limitations that Ant's original author couldn't live with when developing software across multiple platforms. Make-like tools are inherently shell-based -- they evaluate a set of dependencies, then execute commands not unlike what you would issue in a shell. This means that you can easily extend these tools by using or writing any program for the OS that you are working on. However, this also means that you limit yourself to the OS, or at least the OS type such as Unix, that you are working on.
Makefiles are inherently evil as well. Anybody who has worked on them for any time has run into the dreaded tab problem. "Is my command not executing because I have a space in front of my tab!!!" said the original author of Ant way too many times. Tools like Jam took care of this to a great degree, but still have yet another format to use and remember.
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, calling out a target tree where various tasks get executed. Each task is run by an object that implements a particular Task interface.
Granted, this removes some of the expressive power that is inherent by being able to construct a shell command such as `find . -name foo -exec rm {}`, but it gives you the ability to be cross platform -- to work anywhere and everywhere. And hey, if you really need to execute a shell command, Ant has an task that allows different commands to be executed based on the OS that it is executing on.
--------
To this I would add that it is not only a standard amongst open source IDEs for Java but practically all major commercial IDEs support Ant as well.
Re:Ant is for wimps (Score:5, Insightful)
Make is super-powerful but infuriatingly incompatible even across different versions of the same product, such as GNU make.
Ant is easy to learn, after a brief period of warping your brain into their XML way of thinking, executes smoothly and quickly, and is infinitely extensible and very Java-friendly.
There's probably room for both tools in the universe but Ant is well worth learning and adding to one's bag of tricks.
Re:Ant is for wimps (Score:2)
As long as you deal with the Windows and UNIX pathnames well. Mixing Windows-based developers and UNIX-based developers in a project that uses Ant can still be a PITA if not thought out.
Make is super-powerful but infuriatingly incompatible even across different versions of the same product, such as GNU make.
It isn't difficult to write POSIX-compliant makefiles that work pretty much anywhere. Front-ending the makefiles with a shell script can encapsulate all the platform-specific stuff, such as command line options and the compiler to use. Again, it really is not difficult.
Ant is easy to learn, after a brief period of warping your brain into their XML way of thinking, executes smoothly and quickly, and is infinitely extensible and very Java-friendly.
The Java-centricity of Ant is its biggest weakness. Having to learn Ant for Java and make for everything else is just not good. I just use make for everything and my life is simpler for it.
Re:Ant is for wimps (Score:1)
Why would you want to use an inferior tool like Ant just for "the abiity to be cross platform" ??? This is where their argument really falls flat. After all, Ant is a Java tool, right? Java is cross platform. You compile it on one platform and run it on many others -- you don't recompile your Java code on each platform! Where's the need for a cross platform Java build tool? This really doesn't make any sense at all.
Well we use multiple platforms for development (Linux, NT, XP, Win2000) and Ant (plus xdoclet and JUnit) makes it easy for us to just get the code from CVS and have it compile and run straight off on any platform, no messing.
Re:Ant is for wimps (Score:2)
Ummm... this is open source.
People download the source and modify and compile it on whatever platform they want.
Ant was specifically written to make it easier for people to compile Tomcat 3.x across a variety of platforms.
Distributing a set of makefiles that would work on all possible platforms was a nightmare, writing a simpler cross-platform tool was the best solution.
Unfortunately the users of that tool then went and decided that it suitable for all java development, and Ant was unleashed on the world.
Re:Ant is for wimps (Score:1)
Re:Ant is for wimps (Score:1)
Re:Ant is for wimps (Score:1)
Re:Ant is for wimps (Score:2)
So modders tend to mod down what they dissagree with, as they allready choosed to mod and not to post.
angel'o'sphere
Re:Ant is for wimps (Score:5, Insightful)
Make is great when you're developing on Unix. But try and move a makefile for a complex build from Unix to Windows and see how well it works. If you're using Ant, and you've done a decent job with your build.xml file and aren't calling too many "execs", the ant build is quite likely to work with minimum effort.
Ant is a cross-platform version of make, and by cross platform I mean the your build process can work the same on many evironments with little effort. Sure you can get gmake for windows. But then you'll need to get bash, cp, cat, rm, etc for Windows too.
Re:Ant is for wimps (Score:1)
No, that's not true. I can run my makefiles on Unix or Windows and I don't need "cat", "rm" and such on the Windows box... If you properly structure your makefile, you can avoid these platform dependencies.
For example, instead of embedding the Unix commands into your targets, like this:
target: dependency
rm -f myfile.ext you simply write it like this:
target: dependency
$(RM) myfile.ext
at the top of each makefile, I do an "include platform.cfg" which sets up RM to be "rm -f " for Unix, "del" for Windows, etc. Porting the build process to a new platform means writing a platform.cfg file ONCE and then using it on many different projects.. Most of my .cfg files were written many, many years ago and they still work perfectly.
Re:Ant is for wimps (Score:1)
Reminds of Maslow's quote: "If the only tool you have is a hammer, every problem begins to look like a nail" (or something similar).
Sure, you can solve the problem with make, but you have an extra step that's not necessary with Ant as all the tasks are written in Java and therefore cross-platform without requiring platform-specific configuration.
Make is great for development where the specifics of the platform are important but, in my opinion as a Java developer, Ant is better suited to Java development.
Re:Ant is for wimps (Score:2)
Bah!
The step's there, it's just that the Ant developers have already done the work.
Getting Ant to work on Netware was an amusing exercise to watch.
Ant isn't really anymore cross-platform that the solution suggested by the previous poster, it just hides the platform differences in a different place.
If he writes a platform.cfg and uses it for every project then the "extra step" is already done, and his solution is pretty much the same as Ant.
Re:Ant is for wimps (Score:2)
It can work very well. MKS and others provide a good make program and many of the supporting UNIX tools for Windows. Putting platform-dependent shell scripts in front of make encapsulates differences and makes supporting multiple platforms no more or less difficult than with Ant (the platform differences remain no matter the build tool you use). Also, using the non-standard GNU make extensions is simply not a good idea in any context, unless you can guarantee GNU make is installed in every context. Sticking to POSIX is much easier in the long run.
What would really be better than Ant, is a Java implementation of the MKS toolkit or something similar.
Re:Ant is for wimps (Score:2)
Not to be trolling or anything but anyone using make would have those tools on his windows box anyway. First thing a true unix geek does on a windows box is install CYGWIN.
Re:Ant is for wimps (Score:2)
No it's not.
It's a cross-platform tool that attempts to solve a similar problem to that solved by make.
Make is a hell of a lot more powerful than ant, but some people are willing to trade in that power for the perceived simplicity of Ant.
Re:Ant is for wimps (Score:3, Informative)
There is the little problem about tabs and spaces being rendered identically by most software but meaning very different things to make. The authors of make figured out pretty early on that this was a big mistake, but they didn't change it because they didn't want to disrupt their installed user base. Their installed user base at that time was approximately eleven users. If they had taken the bull by the tail and faced the situation, we wouldn't be having this discussion today.
I'm a wimp. Can't read what I can't see.
Re:Ant is for wimps (Score:1)
It is only an issue if your makefile doesn't work. Makefiles are not constantly edited, so once they're working, you leave them alone. When your dependency rules are properly written, you don't need to modify the makefile everytime you add or remove a class.
By the way, if your editor can't easily tell you the difference between a tab and a space, I suggest you get a new editor...
Re:Ant is for wimps (Score:2)
This really isn't a big deal at all. If you have spaces instead of tabs, Make fails in a consistent manner. Big deal. Just don't use text editors that insist on expanding tabs into spaces; those text editors are the problem, not Make.
Re:Ant is for wimps (Score:2)
Ant is a proven product, has a well-defined, well-documented, and *validatable* syntax, unlike make. XML is self documenting anyway, and if you don't like the way it looks when you try to read it directly (?), write an XSLT to have it pretty print any way you like (for example to a nice HTML page with a table).
'make' uses its homegrown bizarre antiquated syntax that is NOT userfriendly, and suffers from an obnoxious reliance on whitespace (tab vs space is important). It is not self-documenting, nor can it leverage the large body of XML tools.
Ant has long since left make in the dust, and the 2nd generation tools like Maven, Gump, and Jelly, which all build on Ant, are the future.
Re:Ant is for wimps (Score:1)
Re:Ant is for wimps (Score:2)
As for the spaces vs tabs issue with make, it is no worse than trying to figure out the syntax of Ant build files.
I need to be able to do the following tasks:
Re:Ant is for wimps (Score:1)
Re:Ant is for wimps (Score:2)
The basic idea is when make detects a java file has changed, it adds the file name to a list. When all the adding is done, javac is called on this list. My compile times are great and I have the full power of Make.
The book is divided (Score:2, Insightful)
It sounds to me like it's equally UNappropriate for all audiences. If I'm a beginner, I want a whole book for me, same with intermediate of expert. There are exceptions to every rule, but that model sounds better than I think it will work.
Re:The book is divided (Score:3, Interesting)
Re:The book is divided (Score:2)
By the time you've read the first eight chapters you ready to either write your own build files, up to and including junit testing and deployment. So you can stop reading there if you want. But at that point you will probably need to look at one or two of the advanced topics, depending on what you want. Doing webapps? read ch12, Doing EJB? Ch 14. Soap? chapter 15.
The final section, extending ant sems a bit off topic to pure ant consumers, but we wanted to show it is easy to do, when Ant doesnt meet all your needs. Its easy to integrate other java code into Ant.
I Think there is still scope for a single 'Ant Internals' book that focuses on the code, explains the IntrospectionHelper, how tasks work, covers task testing, etc etc. But that is a niche product, you need to be a core ant developer to want that book. And we have the mail list and the source in that situation.
Re:The book is divided (Score:3, Interesting)
You can skip the first eight chapters then
You still might want to look at some of the advanced subjects, such as how to compile jni native code using , then run junit tests against it, how to set up cruise control or the gump to rebuild your code hourly, how to build C# clients to interop test your web service, etc.
If we'd stopped at the first section and added a rewritten task reference you'd be making a valid point. But we wrote the book as a supplement to the docs. After all, our hand is in the docs too, from Ant in anger or Ant Task guidelines (both mine), to all the little corrections we made to the ant docs when we wrote the book and disovered errors.
So use the docs -I think they are really good compared to many other OSS projects, and I am glad you like them. But I think you should still find value in Java Development with Ant. Erik and I really pushed the envelope in section two, doing stuff nobody had done in ant before.
Re:The book is divided (Score:3, Informative)
I can also see your prejudice -I've read the other two ant books and I dont thing they bring enough to the table above the Ant docs. They have a better introductory guide, but once you know ant, that's no longer useful. We wrote ours assuming you have the ant docs open in a different pane of mozilla from the JDK docs, and added stuff that isnt in there. And we fixed ant as we went along when we found problems: you can guess when we wrote chapters by looking at the ant bugzilla entries.
My recommendation would be have a look at your local bookshop, sit down in a corner with a coffee and your laptop, and read through bits of it. Pick a chapter related to a project you are working on.
Up on the manning site [manning.com] we have posted a couple of chapters. Ch4 is about junit; I assume you know that already. Chapter15 shows how to build apache axis based web services and how to interop test against
-steve
(pet peeve: books about OSS projects that dont add to the docs and whose authors didnt contribute anything to the project, not even bugreps)
Ant is not what I wanted... (Score:4, Interesting)
Also, there is little consistency in Ant's syntax. Are they planning on creating a schema or a DTD for Ant so I don't have to perpetually debug my scripts by trial and error? What about a debugger? Ant's getting more and more complex as a scripting engine and it's approaching the point where a debugger would really be useful in some cases.
It's do-able (Score:4, Insightful)
This is doable. Well - nearly, anyway. My team uses Ant to build and deploy our Enterprise applications. Essentially, we have Ant build our sources nightly. If everything goes ok, the whole deployment tree gets the
If there is a failure, I get a notification in my mailbox that gives me the Ant output. The server didn't get any updated files, so nothing changed. Simple.
Using Ant, we've been able to work with CVS fairly easily, and other built-in and third-party addons help a great deal. No, it's not make, but for our application which has ~1000 java classes and another ~1000 data and properties files, it just works.
Re:It's do-able (Score:2)
Re:Ant is not what I wanted... (Score:1)
BTW: Ant can easily call you SCC tasks. From CVS but also from Microsoft $ourceSafe
Re:Ant is not what I wanted... (Score:2)
Here you go: DTD for Ant (Score:1)
Re:Ant is not what I wanted... (Score:2)
An ant debugger. Maybe, as part of better GUI tools. Maybe we should add a debug interface to the engine and let people (you?) code one. I usually use tests and checks to verify that jars I'm using exist, to list properties, and the infamous -verbose and -debug switches.
Your rollback need shows a limitation of ant: it isnt an installer, not a real one. We use it a lot for server side deployment; in that context my buil file backs off the old war/ear for emergency restoration later. Because the big problems I have is not that the deploy code doesnt work, but what I deployed is broken...
-Steve Loughran, co-author of Java Development with Ant.
a positive example of open source power! (Score:1)
On another note, I always find it interesting that a book is published on Ant while it is probably the best documented project underneath the Jakarta umbrella.
Ant rocks, but watch out for chmod +x... (Score:1, Interesting)
So if you do an automated deployment of an app that includes some scripts, you'll need to chmod them again before they'll work.
Other than that, Ant rules.
tom
Re:Ant rocks, but watch out for chmod +x... (Score:2)
If you use the task, you can specify the perms on a , so the permissions on your tar distro is all set up. This even lets you create proper tar files on a windows box that doesnt understand permissions at all.
-Steve Loughran, co-author Java Development with Ant
I dislike Ant (Score:3, Informative)
With make files, I can keep everything in one directory (I dislike having a src directory). With make files I can run ispell (I don't know of a spell checker I can use with Ant.) With make files, I can upload to my web site using scp (Is there a Java scp?)
You might want to switch to Ant to make building on different platforms easier. My make files work on Linux, Mac OSX, and Windows with Cygwin, so I don't feel too limited.
Re:I dislike Ant (Score:1)
With Ant, you can also do it, use the task and your done.
You can also write you custom task that will invoke the tool the way you want it.
Re:I dislike Ant (Score:2)
Speaking of conditional complilation.. JavaMake! (Score:2, Offtopic)
Check it out. It can save a *lot* of time.
This book is excellent so far (Score:1)
I had a chance to meet Steve Loughran at Web Services DevCon East [sellsbrothers.com], and he's awesome. His website [iseran.com], including a great paper called When Web Services go Bad [iseran.com]. He also has a SOAP development blog [iseran.com].
Re:This book is excellent so far (Score:2)
Of my presentations, my current favourite is actually
The Wondrous Curse of Interoperability [iseran.com] , where I get to criticise everyone's SOAP implementation, even the one I work, on, Apache Axis. Plus it has excellent mountaineering photos.
There already is a .NET equivalent of Ant... (Score:1)
Hyrid system worked best for me (Score:1)
Who needs tools like Ant and Make (Score:3, Interesting)
Re:Who needs tools like Ant and Make (Score:2, Insightful)
Re:Who needs tools like Ant and Make (Score:5, Informative)
Can you sell ant to a make user? (Score:3, Interesting)
These are the questions I need someone (or some book) to answer. Will this book answer them?
Re:Can you sell ant to a make user? (Score:2)
But I'm going to argue that Ant brings some things to the table you may want
the gump [apache.org] to see the nightly build of everything that uses Ant. The gump also shows that ant does scale up nicely
We do look at migrating from make in part of the book, chapter 9 I recall. We talk about migration and encourage co-existence: call ant from make or vice versa, so different sub-projects can use the ones they work with. I dont like mixing ant and make in one project, where a project means a single deliverable artifact (like a jar file). So I take such a level of project, ant-ify it and then have the master file (ant or make) call down to the sub project using ant.
Steve Loughran.
Great book, great XML editor (Score:3, Interesting)
I bought the book, and that's saying a lot because I'm very cheap. It's a great book that doesn't just teach you how to use Ant, it teaches you how to do lots of things with Ant, like build web services using the excellent Apache Axis [apache.org], which can automatically create a web service from any Java class source file. It also teaches you how to use JUnit [junit.org] to do automated unit testing with Ant, how to use CruiseControl, etc., etc.
A lot of posters have complained that XML isn't very human-readable. I use and highly recommend a great little tool called Pollo [sourceforge.net]. It has built in support for creating Ant build.xml files, as well as Cocoon [apache.org] sitemap files, XML schemas, etc. IMHO, it's got the best XML editing GUI I've found.
Ant is multi-faceted (Score:2, Interesting)
I'm sure that with a clever extension one could write ant modules that compile other languages as well (and Im sure it's already been done).
ANT IS TOO DAMN SLOW (Score:2)
Sorry for screaming, but I hadn't seen that mentioned yet, and it's day two.
Perhaps it's possible to write ant scripts that execute as efficiently as make, but it must not be very easy to do, since I have never seen one.
It's really nice when you're in a compile/edit cycle if it takes only a few seconds for your compile to build you a new version of your system. If it takes a minute you'll be walking around the room getting a coffee, talking to your co-worker, and totally losing your train of thought.
Most make systems I've seen compile java code a zillion times faster than ant. Sure, ant can look deeper into the java files and compile just the classes it has to, whereas with make you frequently have to compile everything. But here's the trouble: make has already finished compiling everything before Ant has even parsed all of its XML.
I really would like to use Ant. It feels like it's the right thing to do. But I can't afford it, my time is too valuable, and it's too damn slow.
Also I find complex Ant scripts FAR more difficult to understand than complex make scripts. Sure for simple build scripts the "tab and space" thing may be an issue--but for less trivial applications these issues wash away and you start wondering where bits of information came from and with Ant you sometimes just don't know.
I've seen Ant scripts break in ways that were not obvious to anybody, and took hours to debug. I've never had such trouble with make unless I was trying to do something brutally stupid with it.
Maybe I'm wrong about all this. I sure hope so, because I would like to have a good Java centric tool. My main concern is that Ant sucks, and yet it's established enough market share that it's locking out further innovation in the area.
I really think Ant blows.
Re:ANT IS TOO DAMN SLOW (Score:3, Informative)
Yes, there is a slow boot time as ant parses the xml file. This is a fault of parsing everything before executing; when a rewrite eventually gets done this will go away. and for short things like the 'clean' target in a big project, this shows.
but what if your project is javac stuff, junit test it, deploy it, httpunit test the deployed? There its the stuff you run that is the slowness. Ant can help here by running stuff in VM, but the bottlenecks really are the # of tests you run, and how long it can take for JSP pages to compile. At least with a fully automated process you can do other things while the testing and deployment goes on.
Also, can I point you to the myrmidion prototype underway in the ant-dev group as one possible nextgen ant. Faster and more coherent.
-Steve Loughran
ps. point taken about debugging. I think ant-based projects are getting so complex we need to start doing better. One think make has is the -n option to show what happens without doing it. Ant doesnt have that as it is the tasks that do dependency work, not the core engine.
Re:biggest complaint about Ant (Score:1)
The XML tags never seemed to be particularly messy to me - I've seen a lot worse.
Re:biggest complaint about Ant (Score:5, Interesting)
Ant is basically a cross-platform scripting language that is really really weak. Really weak. I'm much looking forward to AAP [a-a-p.org] by the programming god Bram Moolenar. This system is the logical extension of make into the 21st century.
Re:biggest complaint about Ant (Score:2)
Alas, now I see that "make" is pretty darn good at what it does. And I see that ANT's XML-based solution to "make"s issues is far less than elegant.
Re:biggest complaint about Ant (Score:2, Insightful)
This is nothing more than opinion - you offer no arguments whatsoever to back it up. I can't believe it got moderated to +5.
Personally, I'm not crazy about reading raw XML in general, but it's not difficult at all in the case of Ant buildfiles. The structure is not very complicated and using XML makes it easy to use a validating editor to check your build files (there are DTDs that work for simple buildfiles out there). This also means that it is easy to write tools to manipulate the build files (XML is easily scriptable and there are lots of parsers already available). Try writing a tool from scratch to deal with Makefile syntax in an hour or two - not very easy. Using XML also makes sense from the standpoing of being able to easily integrate new custom tasks into the tool - each new task doesn't have to invent its own funky syntax. So, I don't think using XML buildfiles is such a bad decision.
No, it's not. It's a build tool and deserves to be evaluated as such. If you're willing to make such blatantly false claims, I wonder how much you really know about Ant or about scripting languages.
Re:biggest complaint about Ant (Score:2)
It is meant to be a declarative language to be interpreted by an engine; there have been multiple implementations of the ant engine (there are two in ant CVS), which can take the same XML declaration and build things because of it.
XML is a different issue. Yes it can be ugly, but compared to the secret tab characters in make, it is better. You can use XML editors (I use jedit) to edit it, and its easy to generate ant build files from higher level specification files using XSLT and other XML processing chains. Or vice versa: there are tools to take ant files and parse and navigate them, such as the IDEA, forte and jedit and plugins, or the vizant ant project visualiser.
Also look at maven [apache.org]
which is a high level wrapper around ant for real project work.
But thank you for your AAP pointer; i will look at it.
Steve Lougran.
Re:biggest complaint about Ant (Score:2)
Re:biggest complaint about Ant (Score:2)
The XML mess is far worse than the tab issue.
Make files are much better once you get used to them. They are so much more terse you can follow what is going on. XML is a disastrous choice - it makes something which should be simple fucking awkward.
The cross platform abilities are kinda useful but not that hot. If you're doing anything non-standard you end up needing exec and then you have to deal with the same cross-platform problems as you would with make.
The superior dependency management in make means that well written make files are much faster as well as being much smaller and easier to understand.
Re:biggest complaint about Ant (Score:5, Insightful)
"XML is not meant for humans to read, XML is not meant for humans to read..."
XML is way of structuring information so it is easy for software to parse and read, not people. By the same token, it's also not meant to be typed by hand (although it can be). I use Netbeans 3.4 to generate and create my build scripts (an all my other java development
Pretty easy. Way easier than make and makefiles.
Sure the syntax is a bit inconsistant, but that's mainly because Ant growns by incorporating lots of externally created custom tasks into the base. It also gets released fairly often so there isn't a lot of time to refactor those new custom tasks to make them "look" like the old ones....if it ain't broke, don't fix it.
No matter what, the bottom line is that Ant makes Java development easier, faster and more manageable. Id rather have inconsistant syntax and a powerful, efficient build system than the consistant syntax any day.
BTW, If you are so disappointed with the way Ant is made, download the source, fix the "problems" you see and contribute it back...it is, after all, Open Source
Re:biggest complaint about Ant (Score:4, Insightful)
Re:biggest complaint about Ant (Score:1, Insightful)
host=myhost.com
Port=7876
Protocol=http
File
or
<Server>
<host>myhost.com</host>
<port>7876</port>
<protocol>http</protocol>
<files>
<entry>one.html</entry>
<entry>two.html</entry>
<entry>three.html</entry>
</files>
</Server>
Oh yea, which takes up more bandwidth too? XML May be nice because of its structured markup but plain key=value files (some people call them Properties files) are easier for humans and computers to parse and usually take up less bandwidth. Now, that's not to say that XML doesn't have its place but I think people over-use it. For instance, a three line config file that will only ever be three lines/properties doesn't really need to be XML, does it?
Re:biggest complaint about Ant (Score:3, Insightful)
Now you repeat after me:
XML is also meant for humans to read, XML is also meant for humans to read.
The element type names (tags) hold a semantic value that makes this data representation nicer to work with. I would any day prefer working with XML like rather than a binary representation where same semantic value is missing. You can deduce lots and lots just by looking at an XML document with informative element type names. So far, the semantic value is for human consumption, but lots of research goes on in order to make the meta data usable for machines also.
Re:biggest complaint about Ant (Score:2)
Re:biggest complaint about Ant (Score:2)
Huh?
You must like Visual Basic then. It has the most inconsistent syntax going. And it was built in an adhoc make-it-up-as-you-go fashion.
There is no excuse for sloppy syntax structure.
Take the time to make it right. Otherwise you end up with a mess of things the programmer has to remember, AND it becomes a nightmare to maintain.
Re:biggest complaint about Ant (Score:2)
Number 1, we are not talking about programming languages, but build systems. Whine all you want, it's still better than the other major build system 'make'..
Number 2, if you have ever used Ant you'll know that these so-called inconsistancies are relatively minor and many get fixed with each new release. Clearly, you've never used Ant...
Since I started using Ant on projects, I've actually found them much easier to maintain, since the Ant script usually doesn't change, dick head, the code it compiles, jars and deploys does.
Nice try, troll
Re: Re:biggest complaint about Ant (Score:2)
My point was that XML documents are easier for a program to parse (given the abundance of Sax and DOM parsers available in almost every language). Just beacause an XML document is large and complex for a human to read doesn't mean a program can't read with great ease.
So complaining that it's harder to write by hand than property files is crap because if you had any brains, you'd use an XML editor (like the ones built into Netbeans and just about every other IDE or XML Spy etc).
Reading a spec and using this stuff in the real world are 2 different things...
Re:Repeat after me: (Score:2)
You don't need to edit Ant's XML by hand, Netbeans, IntelliJ and a few others have nice GUI's for doing that...and even if you do, it's not that hard.
Put your real name down next time asshole, so I can put you on my foes list...
Amazon has it for 30% off instead of BN's 20% (Score:4, Informative)
Just trying to save people some cash.
FYI if you don't want to buy b/c the patent issue I have to disagree. If patents are legal there is nothing wrong with following the law. If you don't like the law get off your rear and try to get it changed. (Me i'm too lazy, so I'm trying to inflame you into action!)
Re:Amazon has it for 30% off instead of BN's 20% (Score:1)
They used to do this on all items. (Score:2)
The way they formerly did it was you faxed them a copy of the receipt (at the time from any retailer) and they would beat it by 10% or pay the difference!!! Pretty cool (although not a good business decision in the age of PriceWatch and Shopper.com).
Re:JUnit (Score:1, Troll)
Its possible that your Mom has caught a glimpse of my JUnit.. but its unlikely as it is always in her mouth.
-gerbik
Re:Make + Autoconf Combo is great (Score:1)
For instance, there is this task that ships with Ant:
Available Task [apache.org]
Most of the time in Java you don't have to worry that much about what endianness, etc. that you would normally do with C or C++, so I think in practice Ant does a very capable job.
If one uses BeanShell [beanshell.org] you can also do some pretty powerful custom tasks, including writing light-weight Java scripts (not a typo
I know of a development house that generated a pretty sophisticated code work set system using Ant scripts, add-on tasks, and some bean shell scripts.
It also has some options to avoid recompiling all Java files when only some have changed, just like make.
Any Java project I have seen that uses Ant and distributes source has been very easy for me to compile... I would say as easy as autoconf if not easier... and I've found Ant a lot simpler to learn than autoconf.
Having said that, there are some irritating things with Ant (trying to make filesets out of paths is one that springs to mind). And I am certainly a fan of
Re:Make + Autoconf Combo is great (Score:1)
Re:Make + Autoconf Combo is great (Score:2)
But ant is nice because it is fully x-platform, from MacOS X, OS/400, Netware, Linux, Solaris, NT. Even Win9x, though that raises too many support calls.
Also it is nice because makes dependency model is tied to the local filesystem: its notion of 'needs doing' means dest file is older than source file.
Ant offloads dependencies to tasks, and each task has its own logic. The command talks stright to the database, knows about timestamps of dependencies over the wire, etc.
Sometimes make is better, because it adds dependencies to those dumb unix tools that just 'do' things. Its crufty to do the same in ant with tests and conditional targets. The other failing of Ant is that it doesnt necessarily scale as well as gnu make+autoconf does. We will have to work on that,
-Steve Loughran, co-author Java Development with Ant
Re:IN SOVIET RUSSIA (Score:1)
Why, really? Guess what, in the rest of the world we also develop Ant with Java! [apache.org]