ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11270] - FileSet and DirSet break if the directory does not exist
Date Thu, 15 Aug 2002 23:41:00 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11270>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11270

FileSet and DirSet break if the directory does not exist





------- Additional Comments From scott@alodar.com  2002-08-15 23:40 -------
The following patch adds an errorOnMissingDirectory attribute that suppresses the error 
if set on a fileset.

This allows constructs like:
    <jar
      jarfile="${jar.dist}/${jar.baseName}.jar">
      <fileset dir="${compile.classes}"/>
      <fileset dir="${jar.resources}" errorOnMissingDir="false"/>
   </jar>



[localhost:~/Documents/coding/ant] work% diff -rc jakarta-ant-1.5 jakarta-ant-1.5-modified/
Only in jakarta-ant-1.5/lib: README
diff -rc jakarta-ant-1.5/src/main/org/apache/tools/ant/DirectoryScanner.java jakarta-ant-
1.5-modified/src/main/org/apache/tools/ant/DirectoryScanner.java
*** jakarta-ant-1.5/src/main/org/apache/tools/ant/DirectoryScanner.java Tue Jul  9 
08:27:44 2002
--- jakarta-ant-1.5-modified/src/main/org/apache/tools/ant/DirectoryScanner.javThu Aug 
15 16:19:37 2002
***************
*** 234,239 ****
--- 234,244 ----
      protected boolean isCaseSensitive = true;
  
      /**
+      * Whether a missing base directory is an error.
+      */
+     protected boolean errorOnMissingDir = true;
+ 
+     /**
       * Whether or not symbolic links should be followed.
       *
       * @since Ant 1.5
***************
*** 425,430 ****
--- 430,445 ----
      }
  
      /**
+      * Sets whether or not a missing base directory is an error
+      *
+      * @param errorOnMissingDir whether or not a missing base directory
+      *                        is an error
+      */
+     public void setErrorOnMissingDir(boolean errorOnMissingDir) {
+         this.errorOnMissingDir = errorOnMissingDir;
+     }
+ 
+     /**
       * Sets whether or not symbolic links should be followed.
       *
       * @param followSymlinks whether or not symbolic links should be followed
***************
*** 529,540 ****
              throw new IllegalStateException("No basedir set");
          }
          if (!basedir.exists()) {
!             throw new IllegalStateException("basedir " + basedir
                                              + " does not exist");
!         }
!         if (!basedir.isDirectory()) {
!             throw new IllegalStateException("basedir " + basedir
!                                             + " is not a directory");
          }
  
          if (includes == null) {
--- 544,558 ----
              throw new IllegalStateException("No basedir set");
          }
          if (!basedir.exists()) {
!             if (errorOnMissingDir){
!                 throw new IllegalStateException("basedir " + basedir
                                              + " does not exist");
!             }
!         } else {
!             if (!basedir.isDirectory()) {
!                 throw new IllegalStateException("basedir " + basedir
!                                                 + " is not a directory");
!             }
          }
  
          if (includes == null) {
***************
*** 554,559 ****
--- 572,581 ----
          dirsNotIncluded  = new Vector();
          dirsExcluded     = new Vector();
          dirsDeselected   = new Vector();
+ 
+         if (!basedir.exists() && !errorOnMissingDir){
+             return;
+         }
  
          if (isIncluded("")) {
              if (!isExcluded("")) {
diff -rc jakarta-ant-1.5/src/main/org/apache/tools/ant/types/AbstractFileSet.java jakarta-
ant-1.5-modified/src/main/org/apache/tools/ant/types/AbstractFileSet.java
*** jakarta-ant-1.5/src/main/org/apache/tools/ant/types/AbstractFileSet.java   Tue Jul  9

08:27:33 2002
--- jakarta-ant-1.5-modified/src/main/org/apache/tools/ant/types/AbstractFileSet.java   Thu

Aug 15 16:08:38 2002
***************
*** 90,95 ****
--- 90,96 ----
      private boolean useDefaultExcludes = true;
      private boolean isCaseSensitive = true;
      private boolean followSymlinks = true;
+     private boolean errorOnMissingDir = true;
  
      public AbstractFileSet() {
          super();
***************
*** 103,108 ****
--- 104,110 ----
          this.useDefaultExcludes = fileset.useDefaultExcludes;
          this.isCaseSensitive = fileset.isCaseSensitive;
          this.followSymlinks = fileset.followSymlinks;
+         this.errorOnMissingDir = fileset.errorOnMissingDir;
          setProject(fileset.getProject());
      }
  
***************
*** 282,287 ****
--- 284,299 ----
      }
  
      /**
+      * Sets whether an error is thrown if a directory does not exist
+      *
+      * @param errorOnMissingDir "true"|"on"|"yes" if missing directories cause errors,
+      *                           "false"|"off"|"no" if not.
+      */
+     public void setErrorOnMissingDir(boolean errorOnMissingDir) {
+         this.errorOnMissingDir = errorOnMissingDir;
+     }
+ 
+     /**
       * Sets whether or not symbolic links should be followed.
       *
       * @param followSymlinks whether or not symbolic links should be followed
***************
*** 329,338 ****
                                       + getDataTypeName() + ".");
          }
  
!         if (!dir.exists()) {
              throw new BuildException(dir.getAbsolutePath() + " not found.");
          }
!         if (!dir.isDirectory()) {
              throw new BuildException(dir.getAbsolutePath()
                                       + " is not a directory.");
          }
--- 341,350 ----
                                       + getDataTypeName() + ".");
          }
  
!         if (!dir.exists() && errorOnMissingDir) {
              throw new BuildException(dir.getAbsolutePath() + " not found.");
          }
!         if (!dir.isDirectory() && errorOnMissingDir) {
              throw new BuildException(dir.getAbsolutePath()
                                       + " is not a directory.");
          }
***************
*** 340,345 ****
--- 352,358 ----
          DirectoryScanner ds = new DirectoryScanner();
          setupDirectoryScanner(ds, p);
          ds.setFollowSymlinks(followSymlinks);
+         ds.setErrorOnMissingDir(errorOnMissingDir);
          ds.scan();
          return ds;
      }

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


Mime
View raw message