ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Sahol <>
Subject Re: auto dependency generation?
Date Thu, 11 Apr 2002 05:32:09 GMT
I think I know what the original post is about, or maybe it's just 
similar to my own situation. Mine is with creating EJB jar files for hot 

In general, though, if (1) you are creating many different jarfiles off 
of one build, (2) each jarfile has a core class or classes, and (3) 
may/may not have other class  files needed by the core class(es), then 
you have the potential for a maintenance nightmare. You either 
_manually_ keep track of the dependency classes needed by each core 
class/jar, or, as I have done, you wipe the classes (javac destdir) 
directory, compile the core class and let javac pick up the 
dependencies, jar, then repeat for each jar. This is very wasteful and 
time-consuming, since you end up compiling the same classes when they 
are used in more than one jar. Worse still, since you had to wipe the 
classes directory, there's no way of knowing if you REALLY needed to 
rebuild each jarfile....Ant's jar task will rejar everything since all 
the .class files are "new" each time.

So yes, javac picks up the dependencies quite well, but it's not suited 
for determining jar file contents.

Conor MacNeill wrote:

>>From: []
>>On 04/10/2002 03:10:30 PM, Diane Holt wrote:
>>>There's the <depend> task, but it works once the class files are all
>>>compiled (since it uses them to determine the dependencies).
>>Found that as well...seemed like a backwards thing do
>>do (needing class files to generate dependencies :-)
><depend> really answers the question "What do I need to *recompile* due to a
>change in my source?" It does that by looking at the class file to see which
>other classes a class uses. If any of those classes have changes, the class
>in question needs to be recompiled to make sure it is in sync with the new
>code. <depend> uses class files because it is generally much faster if you
>do not need to parse the source. If you are going to parse the source then
>it probably is just as good to recompile everything.
>In your case, you are interested in dependencies in the opposite direction -
>which classes do I need to exist in order to compile my class? Normally the
>Javac compiler will handle this issue. If a class, which is required, does
>not yet exist, javac will attempt to find a source file by looking at the
>source path.
>>>But won't the Java compiler go compile whatever it needs whenever it
>>>needs it? Does the Interface source file live in some subdir down from
>>>the dir specified in 'srcdir'?
>>Both (the Interface source file and the Class that uses that
>>Interface) java files live in com/blah/blah which is under the srcdir.
>In this case, javac will automatically compile the interface as required. If
>this is not happening, I suspect a problem in your build file. I suggest you
>run ant with the -debug flag and see what files <javac> is considering. If
>you still have problems, send us a snippet of your build file and the debug
>output (zipped).
>To unsubscribe, e-mail:   <>
>For additional commands, e-mail: <>

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

View raw message