Author: peterreilly
Date: Wed Aug 22 01:16:49 2007
New Revision: 568495
URL: http://svn.apache.org/viewvc?rev=568495&view=rev
Log:
Bugzilla 11270: add errorOnMissingDir attribute to fileset
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/contributors.xml
ant/core/trunk/docs/manual/CoreTypes/fileset.html
ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java
ant/core/trunk/src/tests/antunit/types/fileset-test.xml
Modified: ant/core/trunk/CONTRIBUTORS
URL:
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=568495&r1=568494&r2=568495&view=diff
==============================================================================
Binary files - no diff available.
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=568495&r1=568494&r2=568495&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Aug 22 01:16:49 2007
@@ -223,6 +223,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/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=568495&r1=568494&r2=568495&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Wed Aug 22 01:16:49 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/trunk/docs/manual/CoreTypes/fileset.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/fileset.html?rev=568495&r1=568494&r2=568495&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTypes/fileset.html (original)
+++ ant/core/trunk/docs/manual/CoreTypes/fileset.html Wed Aug 22 01:16:49 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/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java?rev=568495&r1=568494&r2=568495&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java Wed Aug
22 01:16:49 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/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java?rev=568495&r1=568494&r2=568495&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java Wed
Aug 22 01:16:49 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/trunk/src/tests/antunit/types/fileset-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/types/fileset-test.xml?rev=568495&r1=568494&r2=568495&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/types/fileset-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/types/fileset-test.xml Wed Aug 22 01:16:49
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]