diff --git a/WHATSNEW b/WHATSNEW
index c409d7295..04bfd98d3 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -333,6 +333,8 @@ Other changes:
* new GreedyInputHandler added.
+* add textfile attribute to the filesmatch condition.
+
Changes from Ant 1.6.4 to Ant 1.6.5
===================================
diff --git a/docs/manual/CoreTasks/conditions.html b/docs/manual/CoreTasks/conditions.html
index 1dc67e26f..86c682bee 100644
--- a/docs/manual/CoreTasks/conditions.html
+++ b/docs/manual/CoreTasks/conditions.html
@@ -236,12 +236,19 @@ or the filenames match the answer is so obvious the detailed test is omitted.
file1 |
First file to test |
- Yes. |
+ Yes |
file2 |
Second file to test |
- Yes. |
+ Yes |
+
+
+ textfile |
+ Whether to ignore line endings when comparing files;
+ default false
+ |
+ No |
diff --git a/src/etc/testcases/taskdefs/condition.xml b/src/etc/testcases/taskdefs/condition.xml
index 2b0aed56c..ed11198e1 100644
--- a/src/etc/testcases/taskdefs/condition.xml
+++ b/src/etc/testcases/taskdefs/condition.xml
@@ -196,9 +196,8 @@
file2="match2.txt" />
${filesmatch-different}
-
+
-
@@ -210,6 +209,32 @@
${filesmatch-match}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -374,12 +399,9 @@
-
-
-
-
-
-
+
+
+
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 5308db050..ecb17e99f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
@@ -22,7 +22,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.FileUtils;
/**
- * Compares two files for bitwise equality based on size and
+ * Compares two files for equality based on size and
* content. Timestamps are not at all looked at.
*
* @since Ant 1.5
@@ -40,6 +40,8 @@ public class FilesMatch implements Condition {
*/
private File file1, file2;
+ private boolean textfile = false;
+
/**
* Sets the File1 attribute
@@ -60,6 +62,14 @@ public class FilesMatch implements Condition {
this.file2 = file2;
}
+ /**
+ * Set whether to ignore line endings when comparing files.
+ * @param textfile whether to ignore line endings.
+ */
+ public void setTextfile(boolean textfile) {
+ this.textfile = textfile;
+ }
+
/**
* comparison method of the interface
*
@@ -78,7 +88,7 @@ public class FilesMatch implements Condition {
//#now match the files
boolean matches = false;
try {
- matches = FILE_UTILS.contentEquals(file1, file2);
+ matches = FILE_UTILS.contentEquals(file1, file2, textfile);
} catch (IOException ioe) {
throw new BuildException("when comparing files: "
+ ioe.getMessage(), ioe);
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java
index ae7dd1d71..744f029ea 100644
--- a/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java
+++ b/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java
@@ -162,6 +162,14 @@ public class ConditionTest extends BuildFileTest {
"filesmatch-different-onemissing");
}
+ public void testFilesmatchDifferentEol() {
+ executeTarget("filesmatch-different-eol");
+ }
+
+ public void testFilesmatchSameEol() {
+ executeTarget("filesmatch-same-eol");
+ }
+
public void testContains() {
expectPropertySet("contains","contains");
}