ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r568496 - in /ant/core/branches/ANT_17_BRANCH: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/types/ src/tests/antunit/types/
Date Wed, 22 Aug 2007 08:17:26 GMT
Author: peterreilly
Date: Wed Aug 22 01:17:25 2007
New Revision: 568496

URL: http://svn.apache.org/viewvc?rev=568496&view=rev
Log:
sync Bugzilla 11270: add errorOnMissingDir attribute to fileset

Modified:
    ant/core/branches/ANT_17_BRANCH/CONTRIBUTORS
    ant/core/branches/ANT_17_BRANCH/WHATSNEW
    ant/core/branches/ANT_17_BRANCH/contributors.xml
    ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTypes/fileset.html
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/DirectoryScanner.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/AbstractFileSet.java
    ant/core/branches/ANT_17_BRANCH/src/tests/antunit/types/fileset-test.xml

Modified: ant/core/branches/ANT_17_BRANCH/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/CONTRIBUTORS?rev=568496&r1=568495&r2=568496&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/branches/ANT_17_BRANCH/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/WHATSNEW?rev=568496&r1=568495&r2=568496&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/WHATSNEW (original)
+++ ant/core/branches/ANT_17_BRANCH/WHATSNEW Wed Aug 22 01:17:25 2007
@@ -187,6 +187,9 @@
 * <javac> has a new attribute - includeDestClasses.
   Bugzilla 40776.
 
+* <fileset> has a new attribute - errorOnMissingDir.
+  Bugzilla 11270.
+
 Changes from Ant 1.6.5 to Ant 1.7.0
 ===================================
 

Modified: ant/core/branches/ANT_17_BRANCH/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/contributors.xml?rev=568496&r1=568495&r2=568496&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/contributors.xml (original)
+++ ant/core/branches/ANT_17_BRANCH/contributors.xml Wed Aug 22 01:17:25 2007
@@ -925,6 +925,10 @@
   </name>
   <name>
     <first>Scott</first>
+    <last>Ellsworth</last>
+  </name>
+  <name>
+    <first>Scott</first>
     <middle>M.</middle>
     <last>Stirling</last>
   </name>

Modified: ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTypes/fileset.html
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTypes/fileset.html?rev=568496&r1=568495&r2=568496&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTypes/fileset.html (original)
+++ ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTypes/fileset.html Wed Aug 22 01:17:25
2007
@@ -98,6 +98,15 @@
       true. See the note <a href="#symlink">below</a>.</td>
     <td valign="top" align="center">No</td>
   </tr>
+  <tr>
+    <td valign="top">erroronmissingdir</td>
+    <td valign="top">
+      Specify what happens if the base directory does not exist.
+      If true a build error will happen, if false, the fileset
+      will be ignored.
+      true.</td>
+    <td valign="top" align="center">No</td>
+  </tr>
 </table>
 
 <p><a name="symlink"><b>Note</b></a>: All files/directories
for which

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/DirectoryScanner.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/DirectoryScanner.java?rev=568496&r1=568495&r2=568496&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/DirectoryScanner.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/DirectoryScanner.java Wed
Aug 22 01:17:25 2007
@@ -252,6 +252,12 @@
     protected boolean isCaseSensitive = true;
 
     /**
+     * Whether a missing base directory is an error.
+     * @since Ant 1.7.1
+     */
+    protected boolean errorOnMissingDir = true;
+ 
+    /**
      * Whether or not symbolic links should be followed.
      *
      * @since Ant 1.5
@@ -610,6 +616,17 @@
     }
 
     /**
+     * Sets whether or not a missing base directory is an error
+     *
+     * @param errorOnMissingDir whether or not a missing base directory
+     *                        is an error
+     * @since Ant 1.7.1
+     */
+    public void setErrorOnMissingDir(boolean errorOnMissingDir) {
+        this.errorOnMissingDir = errorOnMissingDir;
+    }
+
+    /**
      * Get whether or not a DirectoryScanner follows symbolic links.
      *
      * @return flag indicating whether symbolic links should be followed.
@@ -790,8 +807,13 @@
                     }
                 } else {
                     if (!basedir.exists()) {
-                        illegal = new IllegalStateException("basedir " + basedir
-                                                            + " does not exist");
+                        if (errorOnMissingDir) {
+                            illegal = new IllegalStateException(
+                                "basedir " + basedir + " does not exist");
+                        } else {
+                            // Nothing to do - basedir does not exist
+                            return;
+                        }
                     }
                     if (!basedir.isDirectory()) {
                         illegal = new IllegalStateException("basedir " + basedir

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/AbstractFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/AbstractFileSet.java?rev=568496&r1=568495&r2=568496&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/AbstractFileSet.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/AbstractFileSet.java
Wed Aug 22 01:17:25 2007
@@ -65,6 +65,7 @@
     private boolean useDefaultExcludes = true;
     private boolean caseSensitive = true;
     private boolean followSymlinks = true;
+    private boolean errorOnMissingDir = true;
 
     /* cached DirectoryScanner instance for our own Project only */
     private DirectoryScanner directoryScanner = null;
@@ -89,6 +90,7 @@
         this.useDefaultExcludes = fileset.useDefaultExcludes;
         this.caseSensitive = fileset.caseSensitive;
         this.followSymlinks = fileset.followSymlinks;
+        this.errorOnMissingDir = fileset.errorOnMissingDir;
         setProject(fileset.getProject());
     }
 
@@ -393,6 +395,16 @@
     }
 
     /**
+     * Sets whether an error is thrown if a directory does not exist.
+     *
+     * @param errorOnMissingDir true if missing directories cause errors,
+     *                        false if not.
+     */
+     public void setErrorOnMissingDir(boolean errorOnMissingDir) {
+         this.errorOnMissingDir = errorOnMissingDir;
+     }
+ 
+    /**
      * Returns the directory scanner needed to access the files to process.
      * @return a <code>DirectoryScanner</code> instance.
      */
@@ -418,17 +430,18 @@
                     throw new BuildException("No directory specified for "
                                              + getDataTypeName() + ".");
                 }
-                if (!dir.exists()) {
+                if (!dir.exists() && errorOnMissingDir) {
                     throw new BuildException(dir.getAbsolutePath()
                                              + " not found.");
                 }
-                if (!dir.isDirectory()) {
+                if (!dir.isDirectory() && dir.exists()) {
                     throw new BuildException(dir.getAbsolutePath()
                                              + " is not a directory.");
                 }
                 ds = new DirectoryScanner();
                 setupDirectoryScanner(ds, p);
                 ds.setFollowSymlinks(followSymlinks);
+                ds.setErrorOnMissingDir(errorOnMissingDir);
                 directoryScanner = (p == getProject()) ? ds : directoryScanner;
             }
         }

Modified: ant/core/branches/ANT_17_BRANCH/src/tests/antunit/types/fileset-test.xml
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/tests/antunit/types/fileset-test.xml?rev=568496&r1=568495&r2=568496&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/tests/antunit/types/fileset-test.xml (original)
+++ ant/core/branches/ANT_17_BRANCH/src/tests/antunit/types/fileset-test.xml Wed Aug 22 01:17:25
2007
@@ -1,5 +1,15 @@
 <project xmlns:au="antlib:org.apache.ant.antunit" default="all">
 
+  <target name="test-fileset-missing-dir">
+    <path id="missing.path.id">
+      <fileset dir="not present"
+               erroronmissingdir="false"/>
+    </path>
+    <au:assertTrue>
+      <equals arg1="" arg2="${toString:missing.path.id}"/>
+    </au:assertTrue>
+  </target>
+
   <target name="test-fileset-with-if">
     <fileset id="this.xml" dir=".">
       <include if="trigger.include" name="fileset-test.xml"/>



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


Mime
View raw message