From 3b1f2fca74ade338347b53d7f450d5dc1bdea0c9 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 16 Nov 2000 08:59:26 +0000 Subject: [PATCH] Added logging to SourceFileScanner. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268192 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 + .../org/apache/tools/ant/taskdefs/Copy.java | 2 +- .../tools/ant/util/SourceFileScanner.java | 52 +++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 9ccb525b4..e1ed553e8 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -28,6 +28,8 @@ Other changes: * can work on non-Windows platforms with the help of libcabinet. See http://trill.cis.fordham.edu/~barbacha/cabinet_library/. +* now supports passive mode. + Fixed bugs: ----------- diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index ed027a6d4..2560f8846 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -266,7 +266,7 @@ public class Copy extends Task { if (forceOverwrite) { toCopy = names; } else { - SourceFileScanner ds = new SourceFileScanner(); + SourceFileScanner ds = new SourceFileScanner(this); toCopy = ds.restrict(names, fromDir, toDir, mapper); } diff --git a/src/main/org/apache/tools/ant/util/SourceFileScanner.java b/src/main/org/apache/tools/ant/util/SourceFileScanner.java index 7e8a4cae7..ac2d12fc7 100644 --- a/src/main/org/apache/tools/ant/util/SourceFileScanner.java +++ b/src/main/org/apache/tools/ant/util/SourceFileScanner.java @@ -54,6 +54,9 @@ package org.apache.tools.ant.util; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; + import java.io.File; import java.util.Vector; @@ -69,6 +72,15 @@ import java.util.Vector; */ public class SourceFileScanner { + protected Task task; + + /** + * @param task The task we should log messages through + */ + public SourceFileScanner(Task task) { + this.task = task; + } + /** * Restrict the given set of files to those that are newer than * their corresponding target files. @@ -81,24 +93,54 @@ public class SourceFileScanner { */ public String[] restrict(String[] files, File srcDir, File destDir, FileNameMapper mapper) { + + long now = (new java.util.Date()).getTime(); + StringBuffer targetList = new StringBuffer(); + Vector v = new Vector(); for (int i=0; i< files.length; i++) { String[] targets = mapper.mapFileName(files[i]); if (targets == null || targets.length == 0) { + task.log(files[i]+" skipped - don\'t know how to handle it", + Project.MSG_VERBOSE); continue; } File src = new File(srcDir, files[i]); - for (int j=0; j dest.lastModified()) { + if (src.lastModified() > now) { + task.log("Warning: "+files[i]+" modified in the future.", + Project.MSG_WARN); + } + boolean added = false; + targetList.setLength(0); + for (int j=0; !added && j dest.lastModified()) { + task.log(files[i]+" added as "+dest.getAbsolutePath()+" is outdated.", + Project.MSG_VERBOSE); + v.addElement(files[i]); + added = true; + } else { + if (targetList.length() > 0) { + targetList.append(", "); + } + targetList.append(dest.getAbsolutePath()); } } + + if (!added) { + task.log(files[i]+" omitted as "+targetList.toString() + + (targets.length == 1 ? " is" : " are ") + + " up to date.", Project.MSG_VERBOSE); + } + } String[] result = new String[v.size()]; v.copyInto(result);