I am new to Enterprise Java projects. We are trying to use Ant as a portable build tool during development/test. We do not wish to compile java files un-necessarily - so what do we have to do in our ant xml file to achieve this [i.e. if file1.java has not changed and we already have an "up-to-date" .class file, then do not recompile in the interests of reducing the time to build the application].
My understanding is that javac [even with the -depends flag] is not intelligent enough to know when file should be recompiled - is this true?
Thanks for your help and support.
We had the same problem today and came to the conclusion that it always recompiles all the files. I would appreciate if anybody can shed some light on this..
Ant documentation had the following:
Only Java files that have no corresponding class file or where the class file is older than the java file will be compiled.
But I noticed that it works fine as long as you do not have a packages. It seemed to create directories for the pakages in the specified destination. I also noticed that if you copy the resultant class files to the destination directory (from the package dir in the destination), then those files do not recompile.
Found the following from Ant Manual:
The directory structure of the source tree should follow the package hierarchy.
Therefore, maintaining the package hierarchy in the source tree solves this problem. No more will all source files compile when not required.