ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
Subject Re: remove old .class files
Date Wed, 29 Apr 2009 19:07:54 GMT
On Wed, Apr 29, 2009 at 2:03 PM, Mighty Tornado
<mighty.tornado@gmail.com> wrote:
> Can I run the <javac> command in such a way that if I deleted java file
> which was previously compiled, it will remove its .class file from the
> classes directory when it builds again?

That's a limit on how Java works. The Java compiler compares the
timestamp on the resulting classfile with the source file. If the
timestamp on the source is older than the classfile, it doesn't do a
build.

However, this is a one way check: Checking a *.java source against its
*.class object. The Java compiler doesn't go through all the
classfiles and see if there is a corresponding source file. In fact,
it may be almost impossible for this to happen since there isn't
necessarily always a one-to-one correspondence between a source file
and object file.

There is also a problem of knowing where the source is stored since it
is quite common to place the compiled classfiles into their own
directory.

That's why God  created the "ant clean" command. (You do have a
"clean" target in your build.xml file. Right?

-- 
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message