Raminder,
Unless I am misunderstanding your question, that is the default behavior of the javac task:
The source and destination directory will be recursively scanned for Java source files to compile. Only Java files that have no corresponding .class file or where the class file is older than the .java file will be compiled.