ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Donald Strong" <>
Subject RE: Replacing Makefiles
Date Thu, 24 Jul 2003 05:49:11 GMT
Hi Leonardo,

I believe that most of what you want to accomplish can be done using 
<depend> and <javac> tasks.

    <!-- remove out-of-date classes -->
    <depend srcDir="${java.src.path}"
            cache="${classes.dir}/../depcache" />

The depend task is run just before the javac task.
It will remove any class files that it considers out-of-date.
If you specify closure="true" this will include all classes
that indirectly use the out-of-date class, otherwise it will
only delete classes that directly extend or implement the
out-of-date class. Once the classes are deleted by the depend
task, the javac task will correctly build them.

That mostly solves the following problem and is much more efficient than
recompiling everything.
> They want this behavior in order to detect broken code, due to 
> changes on a base class, for example.

The only things it won't do are:
 - delete classes that reference constants in an out-of-date
   class, ie. public final static primitives,
 - delete classes that no longer have a source file, 
   ie. the source file has been removed.

The former can not be detected without parsing the source code.
The latter could be resolved if the depend task deleted all classes
that it could not prove were up-to-date, but I don't think that is 
how it works.

If you really must rebuild everything, call the javac class directly
using a java task. You might put the java files into a file and 
provide the filename as an argument.

        <java classname=""
                   fork="true" >
           <classpath >
               <pathelement location="jdk/lib/tools.jar" />

Have a nice day.

> -----Original Message-----
> From: Leonardo Abreu de Barros []
> Sent: Thursday, 24 July 2003 9:02 AM
> To:
> Subject: Trying to get rid of makefiles
> Hi all,
> I work in a company that has a long history using makefiles. Since I 
> joined it, I proposed to migrate to Ant. Some people resist to 
> changes, some people agree, as long as all benefits provided by the 
> makefiles are covered by Ant.
> I've already reproduced all behaviors but one: currently, all java 
> classes names are declared explicitly in the makefile, and sent to 
> the java compiler. It rebuilds all the class files, at each build. 
> They want this behavior in order to detect broken code, due to 
> changes on a base class, for example.
> The problem is that Ant, specifically the <javac> task, only 
> recompiles ".class" if the timestamp differs from the related ".java" 
> file. I've read on documentation that to detect this kind of broken 
> dependencies, you should perform "clean builds" from time to time.
> I proposed this solution, but it wasn't accepted. They think it's a 
> loss of time (even if it's ridiculous) to delete all ".class" files 
> before calling the compiler. If I'm not able to reproduce this 
> behavior with Ant, they prefer to keep the makefiles.
> Does anyone have any idea of how I could reproduce this behavior 
> using Ant? Any other possible solution?
> Thanks in advance,
> Leonardo Barros
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message