ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Varnavas, Frank" <frank.varna...@gs.com>
Subject patch: <fileset> handling of nonexistent directories
Date Fri, 01 Jun 2001 17:25:36 GMT
I had a requirement that a list of named jar files be resolved in several
'well-known' locations, taking the first one found. 
In this case the directories specified may or may not exist.

I could not find any way in ant 1.3 to do it. Ultimately I wrote a patch
that modifies the behavior of fileset such that

1) the directory need not exist at the time the fileset is created 
2) the scan for files will just return no matches if the directory does not
exist.

The build.xml now looks like:

<!-- comma-separated list of required jars -->
<property name="project.jars" value="foundation.jar" /> 

<path id="project.classpath">
    <pathelement path="${std.classpath}"/>

    <fileset dir="${local.dir}/jar >
        <include name="${project.jars}" />
    </fileset>

    <fileset dir="${master.dir}/jar >
        <include name="${project.jars}" />
    </fileset>

    <pathelement path="${std.jars}"/>
</path>

In the above the master.dir and local.dir may or may not exist.

The patch:

*** jakarta-ant-1.3/src/main/org/apache/tools/ant/DirectoryScanner.java	Fri
Mar  2 07:46:37 2001
--- jakarta-ant-1.3.new/src/main/org/apache/tools/ant/DirectoryScanner.java
Fri Jun  1 12:43:25 2001
***************
*** 651,663 ****
          if (basedir == null) {
              throw new IllegalStateException("No basedir set");
          }
!         if (!basedir.exists()) {
!             throw new IllegalStateException("basedir does not exist");
!         }
!         if (!basedir.isDirectory()) {
!             throw new IllegalStateException("basedir is not a directory");
!         }
! 
          if (includes == null) {
              // No includes supplied, so set it to 'matches all'
              includes = new String[1];
--- 651,657 ----
          if (basedir == null) {
              throw new IllegalStateException("No basedir set");
          }
! 	
          if (includes == null) {
              // No includes supplied, so set it to 'matches all'
              includes = new String[1];
***************
*** 674,680 ****
          dirsNotIncluded  = new Vector();
          dirsExcluded     = new Vector();
  
!         scandir(basedir, "", true);
      }
  
      /**
--- 668,676 ----
          dirsNotIncluded  = new Vector();
          dirsExcluded     = new Vector();
  
!         if ( basedir.exists() && basedir.isDirectory() ) {
! 	  scandir(basedir, "", true);
! 	}
      }
  
      /**
*** jakarta-ant-1.3/src/main/org/apache/tools/ant/types/FileSet.java	Fri
Mar  2 07:46:38 2001
--- jakarta-ant-1.3.new/src/main/org/apache/tools/ant/types/FileSet.java
Fri Jun  1 12:43:49 2001
***************
*** 116,127 ****
              throw tooManyAttributes();
          }
  
-         if (!dir.exists()) {
-             throw new BuildException(dir.getAbsolutePath()+" not found.");
-         }
-         if (!dir.isDirectory()) {
-             throw new BuildException(dir.getAbsolutePath()+" is not a
directory.");
-         }
          this.dir = dir;
      }
  
--- 116,121 ----



Mime
View raw message