git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@568495 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -232,6 +232,7 @@ Ronen Mashal | |||||
| Russell Gold | Russell Gold | ||||
| Sam Ruby | Sam Ruby | ||||
| Scott Carlson | Scott Carlson | ||||
| Scott Ellsworth | |||||
| Scott M. Stirling | Scott M. Stirling | ||||
| Sean Egan | Sean Egan | ||||
| Sean P. Kane | Sean P. Kane | ||||
| @@ -223,6 +223,9 @@ Other changes: | |||||
| * <javac> has a new attribute - includeDestClasses. | * <javac> has a new attribute - includeDestClasses. | ||||
| Bugzilla 40776. | Bugzilla 40776. | ||||
| * <fileset> has a new attribute - errorOnMissingDir. | |||||
| Bugzilla 11270. | |||||
| Changes from Ant 1.6.5 to Ant 1.7.0 | Changes from Ant 1.6.5 to Ant 1.7.0 | ||||
| =================================== | =================================== | ||||
| @@ -923,6 +923,10 @@ | |||||
| <first>Scott</first> | <first>Scott</first> | ||||
| <last>Carlson</last> | <last>Carlson</last> | ||||
| </name> | </name> | ||||
| <name> | |||||
| <first>Scott</first> | |||||
| <last>Ellsworth</last> | |||||
| </name> | |||||
| <name> | <name> | ||||
| <first>Scott</first> | <first>Scott</first> | ||||
| <middle>M.</middle> | <middle>M.</middle> | ||||
| @@ -98,6 +98,15 @@ equivalent to an <code><and></code> selector container.</p> | |||||
| true. See the note <a href="#symlink">below</a>.</td> | true. See the note <a href="#symlink">below</a>.</td> | ||||
| <td valign="top" align="center">No</td> | <td valign="top" align="center">No</td> | ||||
| </tr> | </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> | </table> | ||||
| <p><a name="symlink"><b>Note</b></a>: All files/directories for which | <p><a name="symlink"><b>Note</b></a>: All files/directories for which | ||||
| @@ -251,6 +251,12 @@ public class DirectoryScanner | |||||
| */ | */ | ||||
| protected boolean isCaseSensitive = true; | 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. | * Whether or not symbolic links should be followed. | ||||
| * | * | ||||
| @@ -609,6 +615,17 @@ public class DirectoryScanner | |||||
| this.isCaseSensitive = isCaseSensitive; | 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. | * Get whether or not a DirectoryScanner follows symbolic links. | ||||
| * | * | ||||
| @@ -790,8 +807,13 @@ public class DirectoryScanner | |||||
| } | } | ||||
| } else { | } else { | ||||
| if (!basedir.exists()) { | 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()) { | if (!basedir.isDirectory()) { | ||||
| illegal = new IllegalStateException("basedir " + basedir | illegal = new IllegalStateException("basedir " + basedir | ||||
| @@ -65,6 +65,7 @@ public abstract class AbstractFileSet extends DataType | |||||
| private boolean useDefaultExcludes = true; | private boolean useDefaultExcludes = true; | ||||
| private boolean caseSensitive = true; | private boolean caseSensitive = true; | ||||
| private boolean followSymlinks = true; | private boolean followSymlinks = true; | ||||
| private boolean errorOnMissingDir = true; | |||||
| /* cached DirectoryScanner instance for our own Project only */ | /* cached DirectoryScanner instance for our own Project only */ | ||||
| private DirectoryScanner directoryScanner = null; | private DirectoryScanner directoryScanner = null; | ||||
| @@ -89,6 +90,7 @@ public abstract class AbstractFileSet extends DataType | |||||
| this.useDefaultExcludes = fileset.useDefaultExcludes; | this.useDefaultExcludes = fileset.useDefaultExcludes; | ||||
| this.caseSensitive = fileset.caseSensitive; | this.caseSensitive = fileset.caseSensitive; | ||||
| this.followSymlinks = fileset.followSymlinks; | this.followSymlinks = fileset.followSymlinks; | ||||
| this.errorOnMissingDir = fileset.errorOnMissingDir; | |||||
| setProject(fileset.getProject()); | setProject(fileset.getProject()); | ||||
| } | } | ||||
| @@ -392,6 +394,16 @@ public abstract class AbstractFileSet extends DataType | |||||
| ? getRef(getProject()).isFollowSymlinks() : followSymlinks; | ? 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. | * Returns the directory scanner needed to access the files to process. | ||||
| * @return a <code>DirectoryScanner</code> instance. | * @return a <code>DirectoryScanner</code> instance. | ||||
| @@ -418,17 +430,18 @@ public abstract class AbstractFileSet extends DataType | |||||
| throw new BuildException("No directory specified for " | throw new BuildException("No directory specified for " | ||||
| + getDataTypeName() + "."); | + getDataTypeName() + "."); | ||||
| } | } | ||||
| if (!dir.exists()) { | |||||
| if (!dir.exists() && errorOnMissingDir) { | |||||
| throw new BuildException(dir.getAbsolutePath() | throw new BuildException(dir.getAbsolutePath() | ||||
| + " not found."); | + " not found."); | ||||
| } | } | ||||
| if (!dir.isDirectory()) { | |||||
| if (!dir.isDirectory() && dir.exists()) { | |||||
| throw new BuildException(dir.getAbsolutePath() | throw new BuildException(dir.getAbsolutePath() | ||||
| + " is not a directory."); | + " is not a directory."); | ||||
| } | } | ||||
| ds = new DirectoryScanner(); | ds = new DirectoryScanner(); | ||||
| setupDirectoryScanner(ds, p); | setupDirectoryScanner(ds, p); | ||||
| ds.setFollowSymlinks(followSymlinks); | ds.setFollowSymlinks(followSymlinks); | ||||
| ds.setErrorOnMissingDir(errorOnMissingDir); | |||||
| directoryScanner = (p == getProject()) ? ds : directoryScanner; | directoryScanner = (p == getProject()) ? ds : directoryScanner; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,15 @@ | |||||
| <project xmlns:au="antlib:org.apache.ant.antunit" default="all"> | <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"> | <target name="test-fileset-with-if"> | ||||
| <fileset id="this.xml" dir="."> | <fileset id="this.xml" dir="."> | ||||
| <include if="trigger.include" name="fileset-test.xml"/> | <include if="trigger.include" name="fileset-test.xml"/> | ||||