Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Ant - The Definitive Guide

timothy posted more than 9 years ago | from the ants-are-tiny-bugs dept.

Java 205

pankaj_kumar writes "Apache Ant, the Java replacement for make , belongs to the rare breed of category killer software for automating Java software development tasks. It is an Apache open source project, has won numerous awards, boasts comprehensive online documentation and is used by most Java developers. So, what could a book say that is already not available online?" Read on for Kumar's review of Ant: The Definitive Guide.

As a long time Ant user, I have written many Ant build scripts, automating my builds and speeding up the overall development cycle, mostly relying on its excellent online documentation. As a Java developer, I have admired its simple and intuitive interface and the modular design. So on getting Ant: The Definitive Guide in my hands I wasn't expecting a whole lot new to learn, and thought of using it only as a reference book.

After having the book on my desk for more than a month, though, and occasionally flipping through its pages whenever I would otherwise have consulted the online documentation, I must say that I had been missing out on some very important things: tasks like ftp and war deployment that I was simply not aware of and had never felt the need to look up, but could very well use. The other interesting thing I noticed was that my build scripts became smaller, more modular and easier to read.

Like most books in the The Definitive Guide series, Ant The Definitive Guide assumes a certain level of familiarity with underlying technologies such as Java and XML and focuses on providing complete, reference like details of Ant features and tasks. These description are generously supplemented with examples and code fragments.

But so is the the online documentation for Ant! Will someone gain additional insight in using Ant, or be able to work faster, or make better use of Ant capabilities, by consulting this book, instead of the online documentation for a particular Ant task? To find the answer, I randomly picked two topics -- filesets, an important and oft-used Ant datatype, and javac, a core Ant task -- and compared their online description with the one in the book. Here is what I found.

Besides the datatype definition, explanation of various attributes, sub-elements, and the examples, the book also covers how to specify conditional inclusion or exclusion of certain filename patterns when a property is set (or unset). Though this can be inferred from online documentation by a determined user, this particular use is far from obvious. The coverage in the book also talks about the relationship of the fileset datatype with the javac task, pointing out that the fileset attribute dir is equivalent of javac attribute srcdir, as attribute dir will be confusing in javac: is it referring to source directory or destination directory. This is the kind of insight that really helps a user.

The treatment of the javac task in the book is not much different from the one in the online documentation. Both have almost the same material, though the information in the book is better organized for new users. On the other hand, I found the online documentation to be more complete, especially with respect to the compiler specific options and behavior idiosyncrasies.

Here is a rundown on what the book covers: Chapter 1, Getting Started is a quick primer on Ant, with sufficient details for a new user to start using Ant for very simple build tasks. Chapter 2, Using Properties and Types introduces the building block tasks and datatypes, such as property, condition, fileset, path like structures, selectors and so on, used in other Ant tasks. Chapter 3, Building Java Code covers the tasks and activities around compiling Java source files (ie; javac), organizing the build steps in various targets within a single build scripts and/or across multiple scripts, generating documentation using javadoc and creating distribution jars and zip files. The rest of the chapters are devoted to tasks for specific purposes, such as launching external programs (Chapter 7, Executing External Programs), copying files and manipulating directories either on the same machine or over the network (Chapter 4, Deploying Builds), running JUnit tests (Chapter 5, Testing Builds with JUnit) and so on. There are also separate chapters covering interaction of Ant with XML and XDoclet (Chapter 9, XML and XDoclet) and with Eclipse (Chapter 11, Integrating Ant with Eclipse). The last chapter, Chapter 12, Extending Ant, talks about extending Ant by doing things like adding your own tasks, creating custom filters, writing your own build listeners and loggers etc. This chapter also has a small section on how to embed a script written in one of the supported scripting languages within an Ant script.

As you can see from this outline, the book covers almost everything that is to know about Ant and other related software.

So, what is not so good about this book? Well, I didn't find anything wrong with the topics which are actually covered by the book. Of course, there are additional things that I would have liked to see in the book: (a) A good sample Ant script which could be used as the starting point for most small to medium-sized projects; (b) A more thorough explanation of how dependencies among targets determine the execution sequence and how this fits in with explicit invocation of targets; and (c) pictures to illustrate some of the concepts such as life cycle of an Ant task, selection of files in a fileset and the dependency tree of targets.

Overall, I found the book to be comprehensive, well organized, easy to read and good value for money.


You can purchase Ant: The Definitive Guide from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

Sorry! There are no comments related to the filter you selected.

Make file (2, Informative)

alex323 (901730) | more than 9 years ago | (#13139302)

I like how the make file are XML based. With other makefiles, you get stuck if your tab has a space in it :/ Good review though!

Re:Make file (2, Informative)

Cryptnotic (154382) | more than 9 years ago | (#13139482)

I hated that about it. You can't make a file using just a text editor unless you want to break your fingers on the shift, < and > keys.

Re:Make file (1)

jarich (733129) | more than 9 years ago | (#13139582)

I've fuond enough samples in the bundled set of Ant docs that I only have to customize Ant scripts, not create them.

Re:Make file (4, Informative)

codegen (103601) | more than 9 years ago | (#13140299)

Just like JCL(IBM's job control lanaguage). Read the New Hackers Dictionary description [outpost9.com] of JCL. An excerpt:

"Most programmers confronted with JCL simply copy a working file (or card deck), changing the file names. Someone who actually understands and generates unique JCL is regarded with the mixed respect one gives to someone who memorizes the phone book"

About sums up my opinion of ANT.

Re:Make file (2, Insightful)

truckaxle (883149) | more than 9 years ago | (#13139494)

Whoever decided to use a tab as a delimiter should not be allowed to die a natural death. This "feature" has cause countless hours of loss productivity. At one time the make processor gave some obscure warning on the missing tab and left you scratching your head for hours.

Re:Make file (2, Insightful)

Baki (72515) | more than 9 years ago | (#13139705)

people should use a decent editor such as emacs. its make mode highlights the tabs so you can readily see what's up.

Tab Delimiting Vs Space Aligning (1)

buckhead_buddy (186384) | more than 9 years ago | (#13140840)

Being in the Mac OS X world, there's a big chasm between the practices of tab-delimiting and space-aligning data.

Unix originated the idea of the tab-delimited file as a simple way to delimit fields and records (with a character that was unusable in the field data). But it quickly fell from favor because text editors were inconsistent when 1-byte of data did not equal 1 space on-screen. The tools failed them so they abandoned tab-delimited file formats.

Oddly enough, the ancient Mac OS (pre-OS X) users had big problems with columnar-aligned, fixed length formats for file formats, mailing lists, and database dumps because the users didn't realize that the proportional fonts weren't properly aligning the data. The tools failed them so they adopted tab delimited file formats.

Now that Mac OS and Unix have sort of come together, I find the quality of tools on both sides could use some improvement. I've found a wealth of data editiing tools that make make editing columnar, tab-delimited, or XML data a pleasure to work with.

The real answer is to spend time to improve the tools if you're not the one in control of the formats.

Re:Make file (1)

arcanumas (646807) | more than 9 years ago | (#13139590)

Still, i think it would be fair to say that if your tab does not produce a .. tab, then it is not a... tab. It's something else. :)
Writing Makefiles in editors where the tab is a tab should produce no problems.

Re:Make file (1)

dglo (21986) | more than 9 years ago | (#13139677)

I like how the make file are XML based. With other makefiles, you get stuck if your tab has a space in it

<sarcasm>
Cuz Ant is so forgiving if you leave out a '<' or '>' character...
</sarcasm>

Re:Make file (2, Insightful)

jarich (733129) | more than 9 years ago | (#13139718)

Yeah, but I can ~see~ the missing angle brackets! And with proper indentation, matching in XML elements is trivial...

Of course, most people I know who hate XML write their XML on a VERY long lines, with lots of elements jammed in together, and then they complain that it's hard to read.

Re:Make file (0)

Anonymous Coward | more than 9 years ago | (#13140030)

Yeah but any worthwhile xml editor will show you exactly what's missing.

Re:Make file (-1, Flamebait)

Anonymous Coward | more than 9 years ago | (#13139681)

Get yourself a real IDE with a real editor and stop whining.

a good goodbye to make forever (1, Informative)

Anonymous Coward | more than 9 years ago | (#13139775)

Given that I've spent about 1 year working on legacy makefiles at different companies, I am glad to see make phased out.

I'm much more productive using something other than make for building multi-project software packages.

Re:Make file (1)

quasi_steller (539538) | more than 9 years ago | (#13139810)

Yeah, since xml is so great [xmlsucks.org] and we are not creative enough to develop a better format than xml or makefiles.

fp? (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#13139308)

FP?!?!?!?

captcha: touching!! naw-tee!

mwuhahahaha (3, Funny)

sargosis (807169) | more than 9 years ago | (#13139328)

So, what could a book say that is already not available online?"

Nothing, you have to read it.


Sorry, i just had to...

Re:mwuhahahaha (0)

BlogPope (886961) | more than 9 years ago | (#13139404)

So, what could a book say that is already not available online?"

Nothing, you have to read it.

You can read the book on the "pot" a lot easier than the online version (though I'm sure some Slashdotters have a net erminal there too)

Re:mwuhahahaha (0)

Anonymous Coward | more than 9 years ago | (#13139513)

freakin a

it was a joke you lame arse nuck fut

fp (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#13139342)

someone needs to make it so /. automatically blocks posts containing "fp" or "first post" which are submitted right when stories are posted so moderators don't have to waste mod points rating them down.

similarly (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#13139364)

they should auto-block posts that only contain the words "you fail it"

+5 insightful

Re:similarly (0, Offtopic)

jen0r (792342) | more than 9 years ago | (#13139418)

haha, agreed!

Who cares what you think (1)

poopdeville (841677) | more than 9 years ago | (#13139734)

You fail it.

Re:fp (0)

Anonymous Coward | more than 9 years ago | (#13139586)

STFU you idiot! Don't give them any ideas! You stupid noob.

Ant life cycle... (4, Funny)

op12 (830015) | more than 9 years ago | (#13139352)

So, what is not so good about this book?...Of course, there are additional things that I would have liked to see in the book: (c) pictures to illustrate some of the concepts such as life cycle of an Ant

Here ya go:
Life Cycle [rinconvitova.com]

Make file (-1, Redundant)

alex323 (901730) | more than 9 years ago | (#13139353)

I like how the make file are XML based. With other makefiles, you get stuck if your tab has a space in it :/ Good review though!

GUI (1)

hattan (869918) | more than 9 years ago | (#13139396)

Is there a graphical application to help generate ant build scripts? Maybe it will help those starting out in Java get familiar with ANT. A lot of new programmers I talk to are afraid to use ANT because it looks complicated.

Ant IS complicated (1)

mekkab (133181) | more than 9 years ago | (#13139466)

Inheriting fully-formed Ant scripts for a big build and then having to add in your new units is not only daunting, but confusing as well.

But its just like makefiles... stop being scared, figure it out, and then welcome to the world of easy-builds.

(or you could just add your object files to the jars by hand...)

Re:GUI (0, Flamebait)

malraid (592373) | more than 9 years ago | (#13139564)

ANT is a tool for *programmers*. A GUI ?? I don't think that's a good idea. It's just like VB monkeys making GUIs that can't do shit, because they haven't written a single line of code !!! Compared to writing any half decent java program, I find ANT to be easy and simple to make simple tasks. The documentation has LOTS of examples. Am I being elitist? Maybe...I don't like people who think they can program with only a mouse. Sorry, that's my opinion.

Re:GUI (2, Insightful)

Reverend528 (585549) | more than 9 years ago | (#13139712)

Well, contrary to popular belief, XML wasn't really meant to be directly edited by humans. Large nested structures become exceptionally difficult to read and there's not really a clear way to break them down into smaller abstract parts. Not to mention, it's a rather verbose language (compared to something like lisp which has a nearly identical structure with half as much syntax).

If there isn't a GUI for editing ant files, there really should be.

Re:GUI (4, Informative)

madth3 (805935) | more than 9 years ago | (#13139708)

A graphical aproach I've seen to handle ant scripts is done by NetBeans. Starting with version 4 all the project management is ant-based and you can add targets and parameters from the IDE.
Last time I used it the paths were added as absolute paths so I continued editing my scripts by hand, though.

Re:GUI (1)

jarich (733129) | more than 9 years ago | (#13139742)

Look at docs that come with Ant. I think it's the docs/manual/index.html

There are examples of how to use every task. It's really pretty easy once you get started.

Re:GUI (2)

it_flix (808213) | more than 9 years ago | (#13139771)

Doesnt eclipse use Ant for its builds?
Just figure out how they generate their ant scripts...

Price-wares. (0)

Anonymous Coward | more than 9 years ago | (#13139397)

"You can purchase Ant: The Definitive Guide from bn.com."

Or you can find a copy at your local used book store for $2.00

Only two words necessary (1)

greg_barton (5551) | more than 9 years ago | (#13139399)

Use Maven. :)

Basically (0, Flamebait)

Safety Cap (253500) | more than 9 years ago | (#13139434)

Make is for kiddiz,

Ant is for Toddlers,

Maven is for Adults

Re:Basically (3, Funny)

Karma Farmer (595141) | more than 9 years ago | (#13140537)

Make is for C programmers,

Ant is for Java programmers,

Maven is for idiots.

Re:Only two words necessary (2, Interesting)

puppetman (131489) | more than 9 years ago | (#13139456)

I have a web service application that resides as a seperate module in CVS. I needed the ability to build a JAR, and move it either to local qa application servers, or a remote server.

I thought I'd try Maven. After spending 4 hours looking for and reading what passes for documentation on the Apache site, I gave up, and wrote a batch script to do it in 15 minutes.

The Apache docs suck for many of their projects (Tomcat, Maven, Axis). Do the developers do it on purpose so that they can make money writing books explaining the tools? I have no idea.

To be fair, some Apache documentation is good (in the commons projects, like CLI and HttpClient).

Re:Only two words necessary (1)

jbrownc1 (589652) | more than 9 years ago | (#13140819)

I wish someone would write a book about Maven that was as helpful as this Ant book sounds like it might be. I am also put off by the not-quite-helpful documentation on the Maven site.

Re:Only two words necessary (2, Informative)

Anonymous Coward | more than 9 years ago | (#13139814)

Maven has serious issues as eloquently explained by Hani [jroller.com] . Be sure to check out his newest article on mergere [jroller.com] , the company that attempts to support maven.

Save Money (0, Informative)

Anonymous Coward | more than 9 years ago | (#13139444)

Save more than FOUR BUCKS by buying the book here: Ant - The Definitive Guide [amazon.com]

Bookpool has it cheaper than bn.com (3, Informative)

COBOL/MVS (196516) | more than 9 years ago | (#13139460)

This book is cheaper at bookpool.com ($22.50) than at bn.com ($27.96 bn price/$25.16 member price). Get it there and save a few $$.

Re:Bookpool has it cheaper than bn.com (1)

poopdeville (841677) | more than 9 years ago | (#13139763)

Or wait for the torrent and get it free.

Kumar? (1, Funny)

Anonymous Coward | more than 9 years ago | (#13139462)

What kind of name is Kumar? What is that like 5 o's or 2 u's?

Re:Kumar? (0)

Anonymous Coward | more than 9 years ago | (#13140516)

Harold. .

Necissity if you use Ant (2, Insightful)

Anonymous Coward | more than 9 years ago | (#13139464)

I have worked on a couple products which have used ant as the build system. These were released a few years ago and I think the version was ant 1.3. The online doc at the time ~2002 was mediocre. I think it has gotten better now, but the book still covers all the basic features you will ever need and decreased our old make full build time from 30-40 minutes to about 10 with ant on the same hardware, as well as making it much easier to make changes and add new steps. When making minor changes ant will recompile and determine dependencies in just a few seconds where our make system would still take 5-10 minutes just for incremental change. Granted our make system could have been optimized, ant was a good excuse to start over. I have a paper copy, but do also use safari to search through the text. This gives you the best of being online and having the book.

Not as good as MakeXS ... (0)

Anonymous Coward | more than 9 years ago | (#13139486)

Seriously though, Ant's biggest problem is Java. GNU Make is so lightweight.

I know the moderators will tag me, but... (0)

Imposter_of_myself (636697) | more than 9 years ago | (#13139514)

I know the moderators will hit me for this, but from the sys admins point of view - ant is evil! It is simply another build program to learn. The C and C++ stuff for the kernel is "make" - now I have to learn "ant" for Java programs. I am not against learning new things, but where some people see XML as a good thing - I think it sucks! I despise any time I see a config file that is XML. XML is for the "parsing impaired" - use a plain text file like everything in /etc !!!

Re:I know the moderators will tag me, but... (3, Insightful)

Decaff (42676) | more than 9 years ago | (#13139591)

I know the moderators will hit me for this, but from the sys admins point of view - ant is evil!

Ant isn't for sys admins.

It is simply another build program to learn. The C and C++ stuff for the kernel is "make" - now I have to learn "ant" for Java programs.

As Java isn't used (yet!) for kernel stuff, what is the problem?

I am not against learning new things, but where some people see XML as a good thing - I think it sucks! I despise any time I see a config file that is XML. XML is for the "parsing impaired" - use a plain text file like everything in /etc !!!

Sorry, wrong way around. XML was designed specifically from the start to be parser-friendly. There are very simple APIs which handle any XML file such as SAX. /etc is a very good example of what is wrong with plain text files - no single program or API could ever handle the range of formats of files there! Incidentally - XML IS plain text.

Re:I know the moderators will tag me, but... (1)

Baki (72515) | more than 9 years ago | (#13139740)

besides, what's stopping you to use make should you create your own java sysadmin tools?

i don't assume that, as a sysadmin, you should have to deal with (java) software that others write, except maybe to install it.

as a sysadmin, dealing with XML and java (1)

wsanders (114993) | more than 9 years ago | (#13140043)

Well, as a sysadmin in a big J2EE shop, I spend about half my time fixing other applications' and other peoples' broken XML, so dealing with ant is no different. Most people around here see ant as a make-equivalent.

I was under the impression that XML was designed to be written and used by machines with little intervention from people. Some people insist it's a programming language. I hope those people burn in heck.

Re:I know the moderators will tag me, but... (1)

Decaff (42676) | more than 9 years ago | (#13140657)

besides, what's stopping you to use make should you create your own java sysadmin tools?

Nothing, except that Ant has a huge amount of support for Java and associated tools. Almost every tool and product developed to assist Java developers provides an Ant library to add functionality. To work with 'make' would be a huge step backwards.

Re:I know the moderators will tag me, but... (1)

Imposter_of_myself (636697) | more than 9 years ago | (#13139856)

Unfortunately, sys admins run across ant when they work with tomcat. If you don't want to pull down byte code off the web - you want to "build" tomcat to get the latest version - then you have to encounter ant. XML, in my book, just makes reading config files more complicated. Now, instead of looking at the actual "data", I have to sort through a bunch of noise - the tags.

Re:I know the moderators will tag me, but... (0)

Anonymous Coward | more than 9 years ago | (#13140181)

Right - noise. The noise is what tells both the human and the client program what the data is for. When you look at /etc/passwd, is there any clue what all the fields are for? No. It's a convention that allows you to know that the first field is the username, etc.

With XML, all data is *tagged* according to what it means. The tags are predefined, by the programmer, or by a group agreement, and the meanings are, or should be unambiguous.

I don't think XML should be used everywhere - there is a lot of redundancy. Within a program, it's a waste of memory, processor and bandwidth, but between systems that are written by different programmers, it's one of the better ways to move data and have it be understood.

For configuration files, many people will be looking at them, so you want them to be understood, right? Without a lot of backstudying? Good for that, although I really prefer the Apache config file layout as an example - has the relative unambiguity of XML, but it's a lot more concise, with very few paired tags.

Re:I know the moderators will tag me, but... (1)

Decaff (42676) | more than 9 years ago | (#13140614)

I have to sort through a bunch of noise - the tags

As against what? Some arbitrary and undocumented text format?

Re:I know the moderators will tag me, but... (0)

Procyon101 (61366) | more than 9 years ago | (#13139949)

XML is for the "Parser impared" in that the notation is designed to make it simple to write parsers, rather than make it simple to use the syntax. Parsers are not difficult to write, and once 1 person has written one, everyone can use it... on the other hand, the programmer gets stuck with the syntax of the data forever. XML syntax is mostly noise with a bit of data thrown in and delivers on none of it's promises.

Re:I know the moderators will tag me, but... (0)

Anonymous Coward | more than 9 years ago | (#13140335)

What were those promises, then? Ease of data exchange? Check. Headers alerting the receiving system as to character encoding? Check. Where to find out data format information? Check. Clear separation of formatting chars and data chars? Check. Clearly defining for the rest of the world the meaning of your data? Check.

Then you look at (nearly) any *nix config file, and find that it's a mixture of line noise and printable chars - yeah, that makes sense.

Re:I know the moderators will tag me, but... (1)

Decaff (42676) | more than 9 years ago | (#13140635)

XML syntax is mostly noise with a bit of data thrown in and delivers on none of it's promises.

What utter nonsense! Of course XML has delivered. An example is the Open Office document format, that is XML-based, easy to transform to other formats (such as PDF), and because it is XML (open and documented) is also now accepted by KDE office applications.

Re:I know the moderators will tag me, but... (1)

snookerdoodle (123851) | more than 9 years ago | (#13139606)

'Not sure why you woulda gotten modded down had you just put in the first two sentences because you have a valid point. OTOH, it might be more relevant to a discussion of Ant vs Make than a discussion of a book review on Ant.

I.e.: I see your point (see below), but what does that have to do with this book?

I've been "bilingual" for awhile and that fact landed me in a mixed C++/Java project last year. Some consultants had built some of the java stuff using Ant and it just made things confusing and unnecessarily complex to have builds using both Make and Ant. Eventually all of the build.xml files were converted to makefiles and we were homogeneous.

Mark

Frankly, I don't care about building Java. (4, Interesting)

david.given (6740) | more than 9 years ago | (#13139529)

I want to build generic programs. Java, C, Pascal, Occam, COBOL, shell scripts. This is because the applications I need to build tend to be a mixture of various different paradigms: little tools that are built to produce data massagers that convert offline data into compilable data; metacompilers like yacc and bison; XML preprocessors like xslt; traditional C or C++; documentation builders like Javadoc or WEB... I can't find anything that will handle all this cleanly.

Is there anything out there that is (a) easily deployable (nothing turns off a prospective user than being told to download and install a complicated build system that depends on $LANGUAGE_OF_THE_MOMENT), (b) suitably flexible that I can customise it to work with all my little build tools, and (c) sufficiently elegant that I won't want to vomit looking at my build scripts six months later?

So far, the only thing I've found that works at all is traditional make. Which, I'm afraid, sucks. Makefiles scale very badly (recursive make. Eeeaah), don't handle disparate rulesets well (I want to build these C files with this rule and these with this other rule... oh, wait, I can't), and the dependency handling is practically nonexistent (you can fake to a certain extent with .d files, but that all falls apart as soon as you need to depend on dynamically made files).

A case in point: I maintain the ACK [sf.net] , a portable compiler toolchain that's about 20 years old. The build system is an intricate network is shell scripts and recursive makefiles. It works, but it's largely incomprehensible, very slow, doesn't handle incremental rebuilds, and is going to be a maintenance nightmare should we ever need to do any major revamps. I'd love to replace it; I've gone out actively looking for something better --- and I've failed.

Any suggestions?

This has been a public service rant by a stressed build technician.

Re:Frankly, I don't care about building Java. (0)

Anonymous Coward | more than 9 years ago | (#13139574)

Yeah, neither does this guy:

http://www.jroller.com/page/fate/ [jroller.com]

Re:Frankly, I don't care about building Java. (1, Informative)

Anonymous Coward | more than 9 years ago | (#13139761)

have a look at maven or scons. maven supports a number of languages. you can write plugins to support more. if you can, spend a bit of time with it. most people who hate it expect it to offer instant gratification. as with most ultimately good things, that's never the case.

Re:Frankly, I don't care about building Java. (1)

iabervon (1971) | more than 9 years ago | (#13139798)

Actually, make scales pretty well if you have a single make process read a bunch of files with "include", possibly recursively. It handles having different rulesets if you use static pattern rules. The only problem I haven't been able to solve effectively in my use of make is getting it to recheck dependancies after recomputing them (and I haven't figured out how to pull together the linking requirements of libraries and get each one listed once in the necessary order).

The main thing is that you really want to have a Makefile with all your rules, and have a file of variable definitions for each directory, so that the build system rules don't have to be duplicated everywhere.

I completely agree (1)

HelloKitty (71619) | more than 9 years ago | (#13140011)

Has anyone used Ant with other languages besides Java?

If it's Java only, then I just don't care... scons is pretty neat for c/c++, haven't used it on other languages though.

Re:I completely agree (1, Informative)

Anonymous Coward | more than 9 years ago | (#13140377)

I haven't directly invoked gcc with ant but I have used ant to run build scripts for a c++ project (the scripts run autoconf/automake).

It's a useful thing to do in a mixed j2ee/C++ development environ to provide automated building, unit testing, and documentation for all projects using a uniform set of ant targets (i.e then can run it all remotely with cruisecontrol or similar app)

To run bash shell scripts or do c++ compilation there is an ant extension on sourceforge http://sourceforge.net/projects/ant-contrib/ [sourceforge.net]

Re:I completely agree (1)

DrEasy (559739) | more than 9 years ago | (#13140430)

Well, I don't know if that answers your question, but I use Ant to package my Firefox extension. It has commands for creating zip files and Jars, as well as creating and moving folders, which is all I need.

Ant is extensible, so I wouldn't be surprised if a lot of tasks have been made available for programming languages other than Java.

Using Ant with PHP (1)

mgkimsal2 (200677) | more than 9 years ago | (#13140459)

We're using Ant with PHP. It's working out just fine. I'm preparing an article on an interesting technique we're using to manage multiple projects with a bit of sanity, and Ant is the cornerstone. If you're interested in a draft, email me at mgkimsal@gmail.com or check http://webdevradio.com/ [webdevradio.com] in the next few weeks.

Re:Frankly, I don't care about building Java. (1)

Abcd1234 (188840) | more than 9 years ago | (#13140013)

"I want to build generic programs. Java, C, Pascal, Occam, COBOL, shell scripts."

Well, nice if you to post your complaints in a forum about Ant and Java, then.

Re:Frankly, I don't care about building Java. (0, Troll)

Anonymous Coward | more than 9 years ago | (#13140699)

I use FinalBuilder and never looked back.
I does everything you want and more :) :

http://www.finalbuilder.com/index.html [finalbuilder.com]

Supported compilers (you can also add your own easily) :

Visual Basic Project
VC6 Project
C++ Builder Project
Chrome
Delphi Win32
Borland Resource Script
Delphi .Net Project (D8 and D2005)
Java Compiler
MadExcept
VS.Net Solution
AssemblyInfo Updater
MS C# Compiler
MS C# Project Compiler
MS VB.Net Compiler
MS VB.Net Project Compiler
MS J# Compiler
MS J# Project Compiler
Borland C# Compiler

Ant does the job... (0)

Anonymous Coward | more than 9 years ago | (#13139544)

But I prefer to use make and a Makefile to compile my Java stuff because make is available on every Unix by default.

Windows? There I compile my java stuff too using make in cygwin.

Make is available on more platforms than Java or Ant together.

The best thing about using make and a Makefile instead of Ant is that I don't need to read books like this.

Oh... And I can use make and a Makefile to compile C code and the Java code of the same project.

Re:Ant does the job... (4, Informative)

Decaff (42676) | more than 9 years ago | (#13139617)

Oh... And I can use make and a Makefile to compile C code and the Java code of the same project.

If you understood Ant, you would know that it can do this as well.

Re:Ant does the job... (1)

p2sam (139950) | more than 9 years ago | (#13139773)

You can. But you should not. You're falling into the Turing Tar Pit. The C and C++ building facilities are too immature for now. And the Ant developers certainly are not putting priority in making it work well with C and C++ building anyhow.

FYI: I use Ant to build/test/deploy my Java code.

Re:Ant does the job... (1)

Decaff (42676) | more than 9 years ago | (#13140536)

You can. But you should not. You're falling into the Turing Tar Pit. The C and C++ building facilities are too immature for now. And the Ant developers certainly are not putting priority in making it work well with C and C++ building anyhow.

This is a reasonable point. However, the original post mentioned C or C++ as part of a general Java project, so any support should be adequate. For better or worse, ant is Java-focused, so C and C++ building is not going to be a priority.

Re:Ant does the job... (3, Informative)

Lothsahn (221388) | more than 9 years ago | (#13139746)

The best thing about using make and a Makefile instead of Ant is that I don't need to read books like this.

You don't need to learn make from books because you already know it, and if you knew ant, you wouldn't need to read books like this either.
Even if you didn't know ant, the online documentation is sufficient. That is how I learned ant.

Re:Ant does the job... (1)

publius_ovidius (870895) | more than 9 years ago | (#13139971)

make is awful. Different operating systems have different command line syntax, different path separators, limits to command length, etc. And which make [makemaker.org] are you using? nmake, dmake, bsd make, etc? There are tons of different make programs, many of which are subtly incompatible with one another and sometimes incompatible with different versions of themselves.

So if you can tightly control the operating systems you are distributing to and tightly control the versions of make you are using, make is a fine solution. For those of us who distribute open-source code, make is an absolute nightmare. How many of us want to repond to someone claiming they can't install our software or VMS? Admittedly, some don't care, but I don't want a reputation as someone who distributes non-portable software. (Note, this isn't intended as a flame. Your needs are likely completely different from my own and make may suit them perfectly.)

Re:Ant does the job... (0)

Anonymous Coward | more than 9 years ago | (#13140121)

make is awful.

That is girltalk.

Re:Ant does the job... (1)

HuguesT (84078) | more than 9 years ago | (#13140417)

There is only one true make, and that is GNU make. Works everywhere, including on VMS.

Your complaint belongs in the late 80s or so.

Re:Ant does the job... (1)

publius_ovidius (870895) | more than 9 years ago | (#13140575)

Regardless of whether or not that is true (I wouldn't swear by it), the point is not whether or not everyone can use the particular version of make I want them to use. It's whether or not the version of make they actually do use is compatible with my Makefile. That's why Java has Ant. That's why Ruby has Rake. That's why Perl has Module::Build. That's why more and more open-source software projects are realizing that make doesn't cut it. Just because you think that GNU make is superior to Solaris make (which behaves quite differently in many cases) doesn't mean that that a Solaris shop will easily convince their admin to install your version of make just because you have a personal preference.

You should read up about the limitations [wikipedia.org] of make and compatability [gnu.org] issues of different versions.

Your complaint belongs in the late 80s or so.

Your defense belongs in the late 90s or so :)

Re:Ant does the job... (1)

Shayde (189538) | more than 9 years ago | (#13140437)

But I prefer to use make and a Makefile to compile my Java stuff because make is available on every Unix by default.

This is such a ridiculous assertion. Lets take this apart for a moment.

First of all, Makei s not available on every Unix by default. You have to install it from whatever distribution methodolog you happen to use.

Once it's installed, you STILL have to install the JDK for ANY application you're building, no matter what. You're a java developer, ergo, you need the JDK. With me so far?

If you have the JDK installed, you have a Java VM. Ant uses the Java VM (it's distributed in binary form as a .JAR file. You have to have Java to run it.

So, by your own definition here, every platform you'd be developing or running apps on will run Ant. So much for that excuse.

Moving along. Installation of Ant is TRIVIAL. Unpack the distribution into /usr/ant (or wherever). Do 'export ANT_HOME=/usr/ant; export PATH=$PATH:$ANT_HOME/bin' - or make symlinks as appropriate, and voila, it's installed.

Remember, Ant will run on every system that Java runs on, which is every platform YOU'D be working on.

If you want to use Make because you're used to it, more power to ya, but don't use false statements to justify your own preferences.

SCons (5, Informative)

Chmarr (18662) | more than 9 years ago | (#13139595)

If folk want something better than make, but don't want something so Java-centric. Have a look at SCons [scons.org] .

The software, as well as the confuguration files, are actually Python. But, you won't notice until your build requirements get quite complex.

Scons keeps track of dependencies using MD5sums on the tail nodes. This takes up a bit more processing time, but more than makes up for it with highly-parallelizable builds (SCons + distcc totally rocks), guaranteed correct builds (never do 'make clean' again!).

We've just converted a project from Make to SCons, and it's cut our build time by about 40%. I might even be able to convince our java guys to try it out, too :) (Yes, SCons handles Java as well as C or C++).

Re:SCons (1)

vivek7006 (585218) | more than 9 years ago | (#13140202)

In your experience how stable is SCons? Their website gave me the impression that it is a beta software.

Re:SCons (4, Insightful)

Chmarr (18662) | more than 9 years ago | (#13140655)

At this time, pretty damn solid. Yes, it's 'officially' beta, but they're just polishing the edges now.

The only problems I've run into so far relate to SCons being a little too clever for it's own good, and not 'neatly' letting me do things that make could do. I worked around them, once I understood SCons better

For example, SCons lets you generate static and shareable objects using 'StaticObject' and 'SharedObject', and will 'do what's necessary' to make that work on your platform. Eg, under *nix, it will add '-fpic' to SharedObject. It will also refuse to let you add a StaticObject into a SharedLibrary. Which in most cases is just what you'd want to stop happening, but... if you KNOW that in a particular case it will work, then SCons is getting in the way. Eg, we wanted a .a full of .so files that were compiled with -fpic, and then add that whole .a into a .so. Perfectly valid, but odd, and SCon's structure didn't let us do that easily.

But... there's workarounds and they all 'make sense', but require a little more SCons knowledge. The mailing list is quite active and helpful, though.

If your project is straightforward (even if it's HUGE), then there's no problems at all.

Re:SCons (1)

stefanb (21140) | more than 9 years ago | (#13140445)

Scons keeps track of dependencies using MD5sums on the tail nodes.

I'm not familiar with SCons, but this doesn't compute. The problem with make isn't with recognising changed files, it's identifying dependencies in source files (hence 'make depend').

'make clean' is an artifact of changes to the build environment that are not properly represented in the dependency graph. Looking at SCons, it appears the authors have a few neat ideas, but I fail to see how a different management tool will help in working out the dependencies.

ant is nice if you want to work around the inefficencies of starting up multiple VMs from the command line (the inefficencies should be addressed on the OS/VM level), and if you want a cross-platform build environment if you can't establish a POSIX shell environment. Not particularly bad, but to really brilliant either...

Re:SCons (3, Informative)

Chmarr (18662) | more than 9 years ago | (#13140752)

I glossed over some of the features, and reasons for them, so let me explain.

The 'md5sum' thing ensures that you're not relying on timestamps. Especially important if you're dealing with several machines that might not have their clocks synchronised perfectly. Furthermore, the 'signature' of any of the build nodes is the concatenation of the MD5s of all it's dependencies, PLUS the command lines to generate that node. Change ANY one of those, including changing any compiler flag, and the signature doesn't match, and the node gets rebuilt.

SCons does its own inherent dependency checking, and caches that, too, plus recording the signatures of all the files needed to generate that information. If any of THAT changes, it will re-get dependencies, and then use the result to determine if a node needs to be rebuilt. This, plus the previous part, makes 'make depend' unnecessary. SCons always gets it right, which cannot be said for Make, or (I think) even Ant... (We currently DO have problems with Ant after a 'cvs update'.). I'm pretty sure that you can make your '.depend' files depend on the files that were used to generate it, but the solution [gnu.org] for that for Make (unsure for Ant), is UGLY. SCons handles it all automatically.

SCons also handles cross-platform builds. It's actively tested under *nix and Windows.

Really, if any product deserves to be called a 'category killer' for this category, it isn't Ant, it's SCons.

Perhaps a lot... (0)

Anonymous Coward | more than 9 years ago | (#13139701)

So, what could a book say that is already not available online?

There is so much online information on Linux that it requires expertise just to find it.

As a novice Linux user, I'll take a good Linux book over the Web every time.

JUnit? (2, Interesting)

FranTaylor (164577) | more than 9 years ago | (#13139757)

One of the nicer features of ant, one that doesn't seem to be mentioned, is its JUnit integration. There is a very JUnit reporting mechanism built into ant. It wasn't exactly what I wanted, but with a fairly small modification (superclassing, no actual code mods) I was able to get it to work just as I wanted it to.


Hey, make fiends, try this: add new functionality to make, extending its syntax. PITA, you say. It's very simple with ant.

Additional Ant Goodies (3, Informative)

Robotron2084 (262343) | more than 9 years ago | (#13139782)

This book is also available online at O'Reilly's Safari site.

Also, although Ant is used mainly to build Java, it is NOT java-centric. It can be used to compile any language.

Additional Edit-Compile-Debug Goodies (0)

Anonymous Coward | more than 9 years ago | (#13140215)

"Also, although Ant is used mainly to build Java, it is NOT java-centric. It can be used to compile any language."

For those languages forever tied to the edit-compile-debug cycle.

Forgive my ignorance... (3, Interesting)

Kr3m3Puff (413047) | more than 9 years ago | (#13139803)

Can someone explain to me the difference between Ant [apache.org] and Maven [apache.org] ? I have noticed almost everyone supports Ant, but there are people who also do Maven. Are there any advantages, disadvantages, are the different but overlap greatly, and why does Apache support what appears to me to be two competitive technologies...

Very confusing to someone who just has a high-level understanding of Apache world.

Re:Forgive my ignorance... (2, Informative)

Bjrn (4836) | more than 9 years ago | (#13140372)

Here are two URLs that explain Maven better than I can:

Basically Maven is an extra layer on top of Ant. Or another way of putting it is that Maven is way to program Ant in an XML based language called Jelly. Maven has the concept of repositories and versions, so that you can say that a particular jar file requires specific versions of other jar files in the repository. If you find yourself writing a lot of similar Ant code, Maven is definitely worth a look. It takes a little while to get into, but once you do it is fairly straight forward.

Does it apply to NAnt too? (2, Interesting)

Space_Soldier (628825) | more than 9 years ago | (#13139824)

There is a port of Ant to .NET available from here [sourceforge.net] . It had a great following until MS announced MSBuild. Unfortunetly, MS put RIP on it when they created MSBuild, which comes with .NET. Visual Studio project files are MSBuild files.

My gripes about ant (2, Insightful)

demilurker (571283) | more than 9 years ago | (#13139933)

1. The pulling teeth part! You need to use the 3rd party ant-contrib package to even get basic if-else and for loop functionality. And even then, since it's XML, you end up with crap like this:

<if>
<equals arg1="${foo}" arg2="bar"/>
<then>
<property name="bat" value="barf"/>
</then>
</if>

... give me a break.

What I'm always hoping for is a build system that is just a perl / python library, so I can write the build script in a real language and call the build system when I want to.

2. Ant's simplistic rebuild-on-file-mod way of doing things misses things. Say class A.java calls class B.java. You build and all is well. Then you change B.java's interface, but not where it is called in A.java. By right your build should break now, but ant only rebuilds B.java, because it's file mod time is updated; it does no analysis of what depends on it and should be rebuilt. So you run the program and if that line of code gets called you get a NoSuchMethodError, examine that stack trace, and manually delete the .class file or somesuch. What ant needs is something like what gcc -M does for make.

... hey, I use it, but it's the year 2005 for crying out loud.

Re:My gripes about ant (1)

cratermoon (765155) | more than 9 years ago | (#13140187)

If you knew what you were talking about, you'd know it was javac that does that, not Ant. In fact, Ant has the <depend> task that helps address the shortcomings of javac.

"the rare breed of category killer software" (0)

Anonymous Coward | more than 9 years ago | (#13140078)

Does this sound like hypespeak to anybody else? Sheesh, I'm not sure what that even means. "category killer?" Is the category dead and buried, no longer exists, or did it just get a knock on its phunny b0ne? :)

Ant is simply not a Make replacement (3, Insightful)

Zenin (266666) | more than 9 years ago | (#13140125)

I know Make. Make is a friend of mine. Ant is no Make.

Ant can automate Java builds slightly better then a .bat or shell script...but that's sadly about where it ends.

The major problem is that Ant has no built in dependancy system. Dependant tasks don't count as they have no targets and thus nothing to check for dependancies. All real dependancy checking in Ant is embedded in the Ant task code...which varies task to task and worse yet has little to no documentation (not even documented to be taking place or not!). Examples are javac, zip, copy tasks.

Ant + Javamake gets closer to a Make replacement, but not completely.

But really, to be accurate Ant is a portable .bat/shellscript replacement...and that's it. Claiming it is a legit replacement for Make is to completely misunderstand what Make actually is and does. That doesn't mean Ant isn't useful, it is, but it is no Make.

Re:Ant is simply not a Make replacement (1)

Bjrn (4836) | more than 9 years ago | (#13140641)

Ant has no built in dependancy system

No dependency system? Whatever do you mean? When writing Ant files you configure dependencies between Ant targets. A target in turn has a number of tasks that do the actual work. The if or unless attributes in a target can be used to decide whether to execute the tasks within a target or not. So if you sometimes don't wish to execute a javac, zip or copy task you should place that task in a target with either the if or unless attribute.

Where's the GUI? (1)

ubergeek65536 (862868) | more than 9 years ago | (#13140222)

Another great tool that I'll never use.

Rake (0)

Anonymous Coward | more than 9 years ago | (#13140312)

If you're looking for a very easy make/ant alternative, look at rake, it's written in ruby, and it's damn easy to use. No fiddling with trailing whitespace or xml.

http://rake.rubyforge.org/files/README.html [rubyforge.org] .adam

Just buy FinalBuilder - it's worth it ! (0)

Anonymous Coward | more than 9 years ago | (#13140399)

FinalBuilder uses XML for the build scripts but gives you a nice drag&drop UI, so you never have to write another tag again.

http://www.finalbuilder.com/index.html [finalbuilder.com]

Ant is a Misapplication of Technology (3, Insightful)

aldheorte (162967) | more than 9 years ago | (#13140420)

It has been a source of constant dismay to me that something has not arisen to replace Ant in for Java builds. The Ant project has created a terrific mess where people essentially *program in XML*. XML is a set of data structure markup semantics, not a programming language. No potential of repurposing ant build files exists, another knock against using XML. Therefore, from a software architecture perspective, Ant is one of the biggest misapplications of technology I have seen to date and despite that, staggeringly popular. I rest my case and shake my head.

Java is the real problem (0, Troll)

Anonymous Coward | more than 9 years ago | (#13140588)

The problem isn't Ant - it's Java.

Other than Java's appalling use of resources, why are so many Java programs so crummy? They're supposed to be portable across OS's, but I've never seen a non-trivial one that was. Every one seems to require JVM version 1.2.3.4.5_06_04b built at 1243 on the 14th, or it pukes all over the screen.

Ugh.

- Not a Java fan

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?