Ant Question continued...

Yowza! You guys rule. I posted the Ant question before I left work today, got home, hung out with the fam, took a little nap and received half a dozen answers and calls for clarifications already. Incredible. Since this might help someone else some day, I'm promoting everything up to here. ;-)



You might want to take a look at what the JBoss guys have done - it's a pretty interesting example of splitting an overall project into subprojects, with collaborating ANT-based build files and targets. They have something called 'buildmagic', essentially a collection of custom ANT tasks, that enable developers to focus on building the part of the project on which they're working.

Posted by Jason Brome


Another supporting alternate, which may be more complex than what you are looking for, is to divide up the project into several different sub projects. Each subproject has it's own build file to compile it's piece of the pie. 1 master build file calls each of the subproject's compile. That why each logically component that's untouched doesn't have to be rebuilt when another subproject gets touched. Erik Hatcher's Java Development with Ant ( has a detailed explaination of how to set this sort of thing up.

Posted by Patrick Peak


Hi !

I am Unix/C/ksh. There most be a way for you to only recompile what is needed; using a "Make" utility. But then a makefile needs to be set up. 7000 classes is a lot.

Posted by jean-claude noel


The fundamental fix is to increase the memory available. There are two solutions...

A) set an envirionmental option "ANT_OPTS=-Xmx256m"

B) tweak the javac settings by adding "fork='true' memoryMaximumSize='256m'".

Both have the same effect of increating the heap size for compilation, but I consider B to be superior because 1) the changes is encapsulated in the build.xml and 2) the memory used by javac is in a seperate process so there won't be as much lefover reachable memory and garbage memory to clean up. You will see a 1sec hit in time, but when compileing 7000 classes you won't care.

Posted by Danno Ferrin


Robert Nicholson:

Don't you just have the set the right patternset's for the javac task?

Go check out Jboss source I'm sure it has to deal with large source code base.

What about ant is limiting you? The shell line it needs to run the javac task or something else?

Bob Lee:

Do you mean it runs out of memory or just takes forever?

Jamie McCrindle:

Have you tried Jikes?

btw: are all of the 7000 classes hand coded and part of the same project or are they autogenerated? Splitting them up is going to be guided by the dependencies, as your compiler is going to want access to all of the classes that the current source depends on (i.e. if you split into packages and it needs one of the downstream packages it's going to break).

Okay, so here's the answers and clarifications.

The reason Ant is having problems is the compiler runs out of memory. I'm working on a computer with 256 megs of RAM and there's not much I can do about it (though it is a P4 2Ghz... it's like bicycle wheels on a Ford Mustang). This may be the high end for memory in the office.

We're trapped in Java 1.2.2 for now since that's the "standard". Not sure why, but I get different errors when I try to compile it under JDK 1.4... One step at a time.

I do have compiler flags right now to up the memory, but no the way that Danno has it. I'll try his way tomorrow morning.

We want to move away from make because it's such a nightmare. Right now there's a couple make scripts which read this enormous text file with all the names of the classes (one for Unix and one for Windows) and batch files to move around .jars, etc. We want it all to be wrapped up in a nice workable Ant process, with unit testing, etc.

I was reading O'Reilly's Ant book this afternoon on Safari and saw how to make "cascading build scripts" where one Ant build.xml file calls several others. I was hoping to be able to have a property with package names and just go from there, but if I have to, I'll use this option - or just hack together a build.xml with different targets per package. I started to mess with this this afternoon but started running into dependency problem.s

By the way, I really have NO idea what this code does yet. I mean, I know it's a billing app, but beyond that I'm clueless. I'm just trying to get this stuff to compile right now. This is only part of the problems I'm having, which includes duplicate classes in parts of the app, missing jar files, mystery classes etc. I'm really, really praying that these 7000 files actually do something and are not there as a way to keep people employed. Seriously.

I just remembered that one of my old projects used an Iterate Ant task to grab different modules in the-nightmare-that-is-ATG-Dynamo. I'll have to go see if I can find that out on the internet and try going through the packages that way...

Thanks for the help everyone,


< Previous         Next >