Browse Source

make sure the 'correct' error is reported if the directory doesn't exist. Sync error messages of DirectoryScanner and AbstractFileSet.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@693791 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
4248bab8ea
3 changed files with 16 additions and 12 deletions
  1. +3
    -4
      src/main/org/apache/tools/ant/DirectoryScanner.java
  2. +1
    -1
      src/main/org/apache/tools/ant/types/AbstractFileSet.java
  3. +12
    -7
      src/tests/antunit/types/fileset-test.xml

+ 3
- 4
src/main/org/apache/tools/ant/DirectoryScanner.java View File

@@ -806,17 +806,16 @@ public class DirectoryScanner
if (!basedir.exists()) {
if (errorOnMissingDir) {
illegal = new IllegalStateException(
"basedir " + basedir + " does not exist");
"basedir " + basedir + " does not exist.");
} else {
// Nothing to do - basedir does not exist
return;
}
}
if (!basedir.isDirectory()) {
} else if (!basedir.isDirectory()) {
illegal = new IllegalStateException("basedir "
+ basedir
+ " is not a"
+ " directory");
+ " directory.");
}
if (illegal != null) {
throw illegal;


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

@@ -434,7 +434,7 @@ public abstract class AbstractFileSet extends DataType
}
if (!dir.exists() && errorOnMissingDir) {
throw new BuildException(dir.getAbsolutePath()
+ " not found.");
+ " does not exist.");
}
if (!dir.isDirectory() && dir.exists()) {
throw new BuildException(dir.getAbsolutePath()


+ 12
- 7
src/tests/antunit/types/fileset-test.xml View File

@@ -15,7 +15,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns:au="antlib:org.apache.ant.antunit" default="all">
<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">

<import file="../antunit-base.xml"/>

<target name="test-fileset-missing-dir">
<path id="missing.path.id">
@@ -30,6 +32,15 @@
</au:assertTrue>
</target>

<target name="test-fileset-missing-dir-exception">
<mkdir dir="${output}"/>
<au:expectfailure expectedmessage="not present does not exist">
<copy todir="${output}">
<fileset dir="not present" />
</copy>
</au:expectfailure>
</target>

<target name="test-fileset-with-if">
<fileset id="this.xml" dir=".">
<include if="trigger.include" name="fileset-test.xml"/>
@@ -53,10 +64,4 @@
<au:assertLogContains text="fileset-test.xml"/>
</target>

<target name="all">
<au:antunit>
<fileset dir="${basedir}" includes="fileset-test.xml"/>
<au:plainlistener/>
</au:antunit>
</target>
</project>

Loading…
Cancel
Save