Browse Source

Issue a warning if a java source is found to be modified in the future

relative to the clock on the current machine.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267620 13f79535-47bb-0310-9956-ffa450edef68
master
Sam Ruby 25 years ago
parent
commit
e3f9382295
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      src/main/org/apache/tools/ant/taskdefs/Javac.java

+ 9
- 0
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -252,12 +252,21 @@ public class Javac extends MatchingTask {
*/ */


private void scanDir(File srcDir, File destDir, String files[]) { private void scanDir(File srcDir, File destDir, String files[]) {

long now = (new Date()).getTime();

for (int i = 0; i < files.length; i++) { for (int i = 0; i < files.length; i++) {
File srcFile = new File(srcDir, files[i]); File srcFile = new File(srcDir, files[i]);
if (files[i].endsWith(".java")) { if (files[i].endsWith(".java")) {
File classFile = new File(destDir, files[i].substring(0, File classFile = new File(destDir, files[i].substring(0,
files[i].indexOf(".java")) files[i].indexOf(".java"))
+ ".class"); + ".class");

if (srcFile.lastModified() > now) {
project.log("Warning: file modified in the future: " +
files[i], project.MSG_WARN);
}

if (srcFile.lastModified() > classFile.lastModified()) { if (srcFile.lastModified() > classFile.lastModified()) {
compileList.addElement(srcFile.getAbsolutePath()); compileList.addElement(srcFile.getAbsolutePath());
} }


Loading…
Cancel
Save