From 158906d666a9161639e657ad81ae2c8bead5e5c5 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Fri, 1 Feb 2002 07:24:49 +0000 Subject: [PATCH] test returns false (not an exception) if either file is missing, this provides better update semantics git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271034 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/CoreTasks/conditions.html | 31 ++++++++++--------- .../ant/taskdefs/condition/FilesMatch.java | 10 ++---- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/docs/manual/CoreTasks/conditions.html b/docs/manual/CoreTasks/conditions.html index 577d689d7..0e1b32752 100644 --- a/docs/manual/CoreTasks/conditions.html +++ b/docs/manual/CoreTasks/conditions.html @@ -10,7 +10,7 @@

Conditions

These are the nested elements that can be used as conditions in the -<condition> and +<condition> and <waitfor> tasks.

not

@@ -143,7 +143,7 @@ the tests succeed.

checksum

-

This condition is identical to the Checksum +

This condition is identical to the Checksum task, all attributes and nested elements of that task are supported, the property and overwrite attributes are redundant and will be ignored.

@@ -152,14 +152,14 @@ ignored.

The http condition checks for a valid response from a web server of the specified url.

- + - + - @@ -169,17 +169,17 @@ web server of the specified url.

The socket condition checks for the existence of a TCP/IP listener at the specified host and port.

Attribute Description Required
urlThe full URL of the page to request. The web server must + The full URL of the page to request. The web server must return a status code of <500.. Yes.
- + - + - + @@ -187,24 +187,25 @@ TCP/IP listener at the specified host and port.

Attribute Description Required
server The DNS name or IP address of the server. Yes.
port The port number to connect to. Yes.

filesmatch

-

Test two files for matching. Both files must exist first. +

Test two files for matching. Nonexistence of either file results in "false". This test does a byte for byte comparision, so test time scales with -byte size. NB: if the files are different sizes or the filenames match -the slower test is shortcutted. - +byte size. NB: if the files are different sizes , one of them is missing +or the filenames match the answer is so obvious the detailed test is omitted. + +

- + - + - + diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java index 245205252..58b28222f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java @@ -81,7 +81,7 @@ public class FilesMatch implements Condition { private FileUtils fu = FileUtils.newFileUtils(); /** - * Sets the File1 attribute + * Sets the File1 attribute * * @param file1 The new File1 value */ @@ -112,13 +112,7 @@ public class FilesMatch implements Condition { if (file1 == null || file2 == null) { throw new BuildException("both file1 and file2 are required in fileequals"); } - if (!file1.exists()) { - throw new BuildException("file " + file1 + " not found"); - } - if (!file2.exists()) { - throw new BuildException("file " + file2 + " not found"); - } - + //#now match the files boolean matches=false; try {
Attribute Description Required
file1 First file to test Yes.
file2 Second file to test Yes.