ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/util SourceFileScanner.java
Date Thu, 16 Nov 2000 08:59:26 GMT
bodewig     00/11/16 00:59:26

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Copy.java
               src/main/org/apache/tools/ant/util SourceFileScanner.java
  Log:
  Added logging to SourceFileScanner.
  
  Revision  Changes    Path
  1.49      +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- WHATSNEW	2000/11/10 17:07:19	1.48
  +++ WHATSNEW	2000/11/16 08:59:25	1.49
  @@ -28,6 +28,8 @@
   * <cab> can work on non-Windows platforms with the help of libcabinet. 
     See http://trill.cis.fordham.edu/~barbacha/cabinet_library/.
   
  +* <FTP> now supports passive mode.
  +
   Fixed bugs:
   -----------
   
  
  
  
  1.8       +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copy.java
  
  Index: Copy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Copy.java	2000/11/15 17:45:41	1.7
  +++ Copy.java	2000/11/16 08:59:26	1.8
  @@ -266,7 +266,7 @@
           if (forceOverwrite) {
               toCopy = names;
           } else {
  -            SourceFileScanner ds = new SourceFileScanner();
  +            SourceFileScanner ds = new SourceFileScanner(this);
               toCopy = ds.restrict(names, fromDir, toDir, mapper);
           }
           
  
  
  
  1.2       +47 -5     jakarta-ant/src/main/org/apache/tools/ant/util/SourceFileScanner.java
  
  Index: SourceFileScanner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/SourceFileScanner.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceFileScanner.java	2000/11/15 17:45:41	1.1
  +++ SourceFileScanner.java	2000/11/16 08:59:26	1.2
  @@ -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,7 +72,16 @@
    */
   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 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<targets.length; j++) {
  -                File dest = new File(destDir, targets[j]);
  -                if (!dest.exists() ||
  -                    src.lastModified() > 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<targets.length; j++) {
  +                File dest = new File(destDir, targets[j]);
  +                if (!dest.exists()) {
  +                    task.log(files[i]+" added as "+dest.getAbsolutePath()+" doesn\'t exist.",
  +                             Project.MSG_VERBOSE);
                       v.addElement(files[i]);
  -                    break;
  +                    added = true;
  +                } else if (src.lastModified() > 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);
  
  
  

Mime
View raw message