Browse Source

Bugzilla 11270: add errorOnMissingDir attribute to fileset

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@568495 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
b0bdced687
7 changed files with 66 additions and 4 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +9
    -0
      docs/manual/CoreTypes/fileset.html
  5. +24
    -2
      src/main/org/apache/tools/ant/DirectoryScanner.java
  6. +15
    -2
      src/main/org/apache/tools/ant/types/AbstractFileSet.java
  7. +10
    -0
      src/tests/antunit/types/fileset-test.xml

+ 1
- 0
CONTRIBUTORS View File

@@ -232,6 +232,7 @@ Ronen Mashal
Russell Gold
Sam Ruby
Scott Carlson
Scott Ellsworth
Scott M. Stirling
Sean Egan
Sean P. Kane


+ 3
- 0
WHATSNEW View File

@@ -223,6 +223,9 @@ Other changes:
* <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
===================================



+ 4
- 0
contributors.xml View File

@@ -923,6 +923,10 @@
<first>Scott</first>
<last>Carlson</last>
</name>
<name>
<first>Scott</first>
<last>Ellsworth</last>
</name>
<name>
<first>Scott</first>
<middle>M.</middle>


+ 9
- 0
docs/manual/CoreTypes/fileset.html View File

@@ -98,6 +98,15 @@ equivalent to an <code>&lt;and&gt;</code> selector container.</p>
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


+ 24
- 2
src/main/org/apache/tools/ant/DirectoryScanner.java View File

@@ -251,6 +251,12 @@ public class DirectoryScanner
*/
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.
*
@@ -609,6 +615,17 @@ public class DirectoryScanner
this.isCaseSensitive = isCaseSensitive;
}

/**
* 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.
*
@@ -790,8 +807,13 @@ public class DirectoryScanner
}
} 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


+ 15
- 2
src/main/org/apache/tools/ant/types/AbstractFileSet.java View File

@@ -65,6 +65,7 @@ public abstract class AbstractFileSet extends DataType
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 @@ public abstract class AbstractFileSet extends DataType
this.useDefaultExcludes = fileset.useDefaultExcludes;
this.caseSensitive = fileset.caseSensitive;
this.followSymlinks = fileset.followSymlinks;
this.errorOnMissingDir = fileset.errorOnMissingDir;
setProject(fileset.getProject());
}

@@ -392,6 +394,16 @@ public abstract class AbstractFileSet extends DataType
? getRef(getProject()).isFollowSymlinks() : followSymlinks;
}

/**
* 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 @@ public abstract class AbstractFileSet extends DataType
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;
}
}


+ 10
- 0
src/tests/antunit/types/fileset-test.xml View File

@@ -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"/>


Loading…
Cancel
Save