ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r477976 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/DependSet.java tests/antunit/taskdefs/dependset/test.xml
Date Wed, 22 Nov 2006 00:01:14 GMT
Author: mbenson
Date: Tue Nov 21 16:01:13 2006
New Revision: 477976

URL: http://svn.apache.org/viewvc?view=rev&rev=477976
Log:
fix regression: dependset fails if target directory does not exist
BZ 40916

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java
    ant/core/trunk/src/tests/antunit/taskdefs/dependset/test.xml

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java?view=diff&rev=477976&r1=477975&r2=477976
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java Tue Nov 21 16:01:13
2006
@@ -18,7 +18,9 @@
 
 package org.apache.tools.ant.taskdefs;
 
+import java.io.File;
 import java.util.Iterator;
+import java.util.Vector;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
@@ -30,6 +32,7 @@
 import org.apache.tools.ant.types.resources.Sort;
 import org.apache.tools.ant.types.resources.Union;
 import org.apache.tools.ant.types.resources.Restrict;
+import org.apache.tools.ant.types.resources.Resources;
 import org.apache.tools.ant.types.resources.FileResource;
 import org.apache.tools.ant.types.resources.selectors.Not;
 import org.apache.tools.ant.types.resources.selectors.Exists;
@@ -108,6 +111,27 @@
             super(rc, DATE_DESC);
         }
     }
+    private static class HideMissingBasedir implements ResourceCollection {
+        private FileSet fs;
+
+        private HideMissingBasedir(FileSet fs) {
+            this.fs = fs;
+        }
+        public Iterator iterator() {
+            return basedirExists() ? fs.iterator() : Resources.EMPTY_ITERATOR;
+        }
+        public int size() {
+            return basedirExists() ? fs.size() : 0;
+        }
+        public boolean isFilesystemOnly() {
+            return true;
+        }
+        private boolean basedirExists() {
+            File basedir = fs.getDir();
+            //trick to evoke "basedir not set" if null:
+            return basedir == null || basedir.exists();
+        }
+    }
 
     private Union sources = null;
     private Path targets = null;
@@ -151,7 +175,7 @@
      * @param fs the FileSet to add.
      */
     public void addTargetfileset(FileSet fs) {
-        createTargets().add(fs);
+        createTargets().add(new HideMissingBasedir(fs));
     }
 
     /**

Modified: ant/core/trunk/src/tests/antunit/taskdefs/dependset/test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/dependset/test.xml?view=diff&rev=477976&r1=477975&r2=477976
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/dependset/test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/dependset/test.xml Tue Nov 21 16:01:13 2006
@@ -93,8 +93,20 @@
     </au:assertTrue>
   </target>
 
+  <target name="test9">
+    <au:assertFalse>
+      <available file="test9dir" type="dir" />
+    </au:assertFalse>
+    <touch file="test9.tmp" />
+    <dependset>
+      <srcfileset dir="." includes="test9.tmp" />
+      <targetfileset dir="test9dir" />
+    </dependset>
+  </target>
+
   <target name="tearDown"> 
     <delete file="test4.tmp" />
+    <delete file="test9.tmp" />
     <delete file="older.tmp" />
     <delete file="newer.tmp" />
   </target>



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


Mime
View raw message