You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bob Price <bp...@evergreen.com> on 2000/10/20 20:51:51 UTC

how to supplement javac compile dependencies?

I just joined the list, and couldn't find an archive with prior data or
get the FAQ link on the site to work, so I'll ask a question that
probably has been asked many times.  If so, and you can point me to
prior answers that would be great.

My question is, how can I supplement the dependency checking that the
'javac' task does?  It obviously compares the timestamp between the java
file and the compiled class file and recompiles if the java file is
newer.  But, this is not enough in some cases.

For example, in a package with lots of java files that have already been
compiled, if I change one file in an incompatible way then recompile
using ant, then it only compiles the file that changed, but then the
other compiled classes will be unchanged but will not work since I broke
something that should have been caught at compile time.  It would be
wonderful if ant could figure this out and recompile all effected
classes.  But short of that, is there a mechanism where I can say that
these java files depend upon this other one (like in makefiles), thereby
forcing ant to recompile the other files?

Is the only way to do this to write my own task that checks these
dependencies and deletes the generated class files before calling
'javac' thereby making it recompile?

Thanks for any help!

Bob

Re: how to supplement javac compile dependencies?

Posted by Scott M Stark <Sc...@displayscape.com>.
If you build into a tree separate from the source tree and remove the build tree
at the start of a full build you are guarenteed to avoid this dependency problem.

If you don't want to take the compilation hit then you do have to create a custom
task, but you should only have to subclass the include task and use that with the
existing javac. Say you create such a smartinclude task I would expect you
could use it as:

<javac destdir = "${build.dir}" debug="true" classpathref = "project.class.path">
    <smartinclude name = "com/dscape/core/logging/*" />
    <exclude name = "com/dscape/logging/Log4jPkgCategory.java" />
    <src path = "/usr/local/dscape/src/classes"/>
</javac>

I would think that this would be easier than deleting the class files which you want
to be updated.

> My question is, how can I supplement the dependency checking that the
> 'javac' task does?  It obviously compares the timestamp between the java
> file and the compiled class file and recompiles if the java file is
> newer.  But, this is not enough in some cases.
> 
> For example, in a package with lots of java files that have already been
> compiled, if I change one file in an incompatible way then recompile
> using ant, then it only compiles the file that changed, but then the
> other compiled classes will be unchanged but will not work since I broke
> something that should have been caught at compile time.  It would be
> wonderful if ant could figure this out and recompile all effected
> classes.  But short of that, is there a mechanism where I can say that
> these java files depend upon this other one (like in makefiles), thereby
> forcing ant to recompile the other files?
> 
> Is the only way to do this to write my own task that checks these
> dependencies and deletes the generated class files before calling
> 'javac' thereby making it recompile?
> 
> Thanks for any help!
> 
> Bob
> 


RE: how to supplement javac compile dependencies?

Posted by Alan Gerhard <AG...@E-SyncNet.Com>.
Bob -

You can 'Touch' the affected files, 
	<touch file="myfile" datetime="09/15/1959 2:02 pm" />
or just
	<deltree dir="${classes}"/>

which would force a total recompilation.

alan


-----Original Message-----
From: bprice@mail.evergreen.com [mailto:bprice@mail.evergreen.com]On
Behalf Of Bob Price
Sent: Friday, October 20, 2000 2:52 PM
To: ant-user@jakarta.apache.org
Subject: how to supplement javac compile dependencies?


I just joined the list, and couldn't find an archive with prior data or
get the FAQ link on the site to work, so I'll ask a question that
probably has been asked many times.  If so, and you can point me to
prior answers that would be great.

My question is, how can I supplement the dependency checking that the
'javac' task does?  It obviously compares the timestamp between the java
file and the compiled class file and recompiles if the java file is
newer.  But, this is not enough in some cases.

For example, in a package with lots of java files that have already been
compiled, if I change one file in an incompatible way then recompile
using ant, then it only compiles the file that changed, but then the
other compiled classes will be unchanged but will not work since I broke
something that should have been caught at compile time.  It would be
wonderful if ant could figure this out and recompile all effected
classes.  But short of that, is there a mechanism where I can say that
these java files depend upon this other one (like in makefiles), thereby
forcing ant to recompile the other files?

Is the only way to do this to write my own task that checks these
dependencies and deletes the generated class files before calling
'javac' thereby making it recompile?

Thanks for any help!

Bob