ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs DependSet.java
Date Thu, 27 Jan 2005 17:04:34 GMT
mbenson     2005/01/27 09:04:34

  Modified:    src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
                        DependSet.java
  Log:
  Sync with HEAD
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.23.2.5  +22 -41    ant/src/main/org/apache/tools/ant/taskdefs/DependSet.java
  
  Index: DependSet.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/DependSet.java,v
  retrieving revision 1.23.2.4
  retrieving revision 1.23.2.5
  diff -u -r1.23.2.4 -r1.23.2.5
  --- DependSet.java	9 Mar 2004 17:01:33 -0000	1.23.2.4
  +++ DependSet.java	27 Jan 2005 17:04:34 -0000	1.23.2.5
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2001-2002,2004 The Apache Software Foundation
  + * Copyright  2001-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -24,9 +24,9 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
  -import org.apache.tools.ant.taskdefs.condition.Os;
   import org.apache.tools.ant.types.FileList;
   import org.apache.tools.ant.types.FileSet;
  +import org.apache.tools.ant.util.FileUtils;
   
   /**
    * Examines and removes out of date target files.  If any of the target files
  @@ -77,6 +77,8 @@
    */
   public class DependSet extends MatchingTask {
   
  +    private static final FileUtils     FILE_UTILS = FileUtils.getFileUtils();
  +
       private Vector sourceFileSets  = new Vector();
       private Vector sourceFileLists = new Vector();
       private Vector targetFileSets  = new Vector();
  @@ -90,6 +92,7 @@
   
       /**
        * Add a set of source files.
  +     * @param fs the FileSet to add.
        */
       public void addSrcfileset(FileSet fs) {
           sourceFileSets.addElement(fs);
  @@ -97,6 +100,7 @@
   
       /**
        * Add a list of source files.
  +     * @param fl the FileList to add.
        */
       public void addSrcfilelist(FileList fl) {
           sourceFileLists.addElement(fl);
  @@ -104,6 +108,7 @@
   
       /**
        * Add a set of target files.
  +     * @param fs the FileSet to add.
        */
       public void addTargetfileset(FileSet fs) {
           targetFileSets.addElement(fs);
  @@ -111,6 +116,7 @@
   
       /**
        * Add a list of target files.
  +     * @param fl the FileList to add.
        */
       public void addTargetfilelist(FileList fl) {
           targetFileLists.addElement(fl);
  @@ -118,34 +124,27 @@
   
       /**
        * Executes the task.
  +     * @throws BuildException if errors occur.
        */
  -
       public void execute() throws BuildException {
   
           if ((sourceFileSets.size() == 0) && (sourceFileLists.size() == 0)) {
             throw new BuildException("At least one <srcfileset> or <srcfilelist>"
                                      + " element must be set");
           }
  -
           if ((targetFileSets.size() == 0) && (targetFileLists.size() == 0)) {
             throw new BuildException("At least one <targetfileset> or"
                                      + " <targetfilelist> element must be set");
           }
  -
           long now = (new Date()).getTime();
           /*
  -          If we're on Windows, we have to munge the time up to 2 secs to
  -          be able to check file modification times.
  -          (Windows has a max resolution of two secs for modification times)
  +          We have to munge the time to allow for the filesystem time
  +          granularity.
           */
  -        if (Os.isFamily("windows")) {
  -            now += 2000;
  -        }
  +        now += FILE_UTILS.getFileTimestampGranularity();
   
  -        //
  -        // Grab all the target files specified via filesets
  -        //
  -        Vector  allTargets         = new Vector();
  +        // Grab all the target files specified via filesets:
  +        Vector allTargets = new Vector();
           long oldestTargetTime = 0;
           File oldestTarget = null;
           Enumeration enumTargetSets = targetFileSets.elements();
  @@ -156,7 +155,6 @@
                  // this is the same as if it was empty, no target files found
                  continue;
              }
  -
              DirectoryScanner targetDS = targetFS.getDirectoryScanner(getProject());
              String[] targetFiles      = targetDS.getIncludedFiles();
   
  @@ -169,7 +167,6 @@
                    log("Warning: " + targetFiles[i] + " modified in the future.",
                        Project.MSG_WARN);
                 }
  -
                 if (oldestTarget == null
                   || dest.lastModified() < oldestTargetTime) {
                     oldestTargetTime = dest.lastModified();
  @@ -177,11 +174,8 @@
                 }
              }
           }
  -
  -        //
  -        // Grab all the target files specified via filelists
  -        //
  -        boolean upToDate            = true;
  +        // Grab all the target files specified via filelists:
  +        boolean upToDate = true;
           Enumeration enumTargetLists = targetFileLists.elements();
           while (enumTargetLists.hasMoreElements()) {
   
  @@ -202,7 +196,6 @@
                    log("Warning: " + targetFiles[i] + " modified in the future.",
                        Project.MSG_WARN);
                 }
  -
                 if (oldestTarget == null
                     || dest.lastModified() < oldestTargetTime) {
                     oldestTargetTime = dest.lastModified();
  @@ -217,10 +210,7 @@
               // skip the following tests right away
               upToDate = false;
           }
  -
  -        //
  -        // Check targets vs source files specified via filelists
  -        //
  +        // Check targets vs source files specified via filelists:
           if (upToDate) {
              Enumeration enumSourceLists = sourceFileLists.elements();
              while (upToDate && enumSourceLists.hasMoreElements()) {
  @@ -235,14 +225,12 @@
                       log("Warning: " + sourceFiles[i]
                           + " modified in the future.", Project.MSG_WARN);
                    }
  -
                    if (!src.exists()) {
                       log(sourceFiles[i] + " does not exist.",
                           Project.MSG_VERBOSE);
                       upToDate = false;
                       break;
                    }
  -
                    if (src.lastModified() > oldestTargetTime) {
                       upToDate = false;
                       log(oldestTarget + " is out of date with respect to "
  @@ -251,15 +239,12 @@
                 }
              }
           }
  -
  -        //
  -        // Check targets vs source files specified via filesets
  -        //
  +        // Check targets vs source files specified via filesets:
           if (upToDate) {
              Enumeration enumSourceSets = sourceFileSets.elements();
              while (upToDate && enumSourceSets.hasMoreElements()) {
   
  -              FileSet sourceFS         = (FileSet) enumSourceSets.nextElement();
  +              FileSet sourceFS          = (FileSet) enumSourceSets.nextElement();
                 DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(getProject());
                 String[] sourceFiles      = sourceDS.getIncludedFiles();
   
  @@ -270,7 +255,6 @@
                       log("Warning: " + sourceFiles[i]
                           + " modified in the future.", Project.MSG_WARN);
                    }
  -
                    if (src.lastModified() > oldestTargetTime) {
                       upToDate = false;
                       log(oldestTarget + " is out of date with respect to "
  @@ -279,7 +263,6 @@
                 }
              }
           }
  -
           if (!upToDate) {
              log("Deleting all target files. ", Project.MSG_VERBOSE);
              for (Enumeration e = allTargets.elements(); e.hasMoreElements();) {
  @@ -289,7 +272,5 @@
                 fileToRemove.delete();
              }
           }
  -
  -    } //-- execute
  -
  -} //-- DependSet.java
  +    }
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message