ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <>
Subject Re: Search a folder automatically?
Date Tue, 26 Aug 2008 17:03:21 GMT
Take a look at "filesets". Also, in the <javac> task, you can specify
a "src" directory. All *.java files in that directory will get

If someone creates a new *.java file in the "src" directory, and did
not delete the corresponding *.class files, then the <javac> task will
only compile that new *.java file. If you change the source code in
one *.java file, the <javac> task will only compile that one file and
leave the others alone (as long as you didn't delete the corresponding
*.class files).

Almost all Ant tasks use timestamps to check whether or not it needs
to do a particular task. For example, <copy> won't copy files if the
files in the destination directory have a newer timestamp than the
files in the source directory. <jar> won't rejar files if the
timestamp of the jarfile is newer than all the source files that you
specified are in that jarfile.

Take a look at the <javac> tasks below:


<javac dest="${dest.dir}">
        <fileset dir="${source.dir}"/>
         <fileset dir="${class.dir}"/>

First of all, I always specify a "dest" directory. That way, I can
easily create a clean target which simply deletes the ${dest.dir}.

The first one uses a single "src" directory (which isn't uncommon).
The second form allows me to specify multiple source directories, and
allows me to just put all the files needed for compiling into a single
${class.dir}. To change the classpath, all I have to do is change the
files in the ${class.dir}.

I hope this answers your question.

David Weintraub

On Tue, Aug 26, 2008 at 11:30 AM, David W <> wrote:
> Hi,
> I am a newbie in Ant field so I appreciate any replies from you.
> What I want to do is to let Ant search a folder automatically. If a piece of source code
(say, Java source code) is put into that folder, then Ant finds the code and begin to do more
work. Can anybody tell me how to make Ant to search a folder automatically?
> Thanks so much!
> David

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

View raw message