Hi David, Thanks so much for your reply. I use apache-ant-1.7.1 on Linux. I found that my old Java source code still got compiled and run even though I left the old corresponding compiled class file there. What I wanted Ant to do is to check a folder continuously (or check the folder once every 3 or 5 minutes) to see if a new source code comes. If it is, then it goes to do more work. Otherwise it just either continue to search or go to sleep again. Is this possible? Thanks again, David W.
--- On Tue, 8/26/08, David Weintraub <[EMAIL PROTECTED]> wrote: From: David Weintraub <[EMAIL PROTECTED]> Subject: Re: Search a folder automatically? To: "Ant Users List" <[email protected]>, [EMAIL PROTECTED] Date: Tuesday, August 26, 2008, 10:03 AM Take a look at "filesets". Also, in the <javac> task, you can specify a "src" directory. All *.java files in that directory will get compiled. 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 src="${source.dir}" dest="${dest.dir}" classpath="${classpath}"/> <javac dest="${dest.dir}"> <src> <fileset dir="${source.dir}"/> </src> <classpath> <fileset dir="${class.dir}"/> </classpath> </javac> 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 [EMAIL PROTECTED] On Tue, Aug 26, 2008 at 11:30 AM, David W <[EMAIL PROTECTED]> 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 > > >
