You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2005/12/23 17:47:15 UTC
svn commit: r358828 - in /ant/core/trunk: ./ docs/manual/CoreTasks/
src/etc/testcases/taskdefs/ src/main/org/apache/tools/ant/taskdefs/condition/
src/testcases/org/apache/tools/ant/taskdefs/
Author: mbenson
Date: Fri Dec 23 08:47:09 2005
New Revision: 358828
URL: http://svn.apache.org/viewcvs?rev=358828&view=rev
Log:
add textfile attribute to filesmatch condition.
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/docs/manual/CoreTasks/conditions.html
ant/core/trunk/src/etc/testcases/taskdefs/condition.xml
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewcvs/ant/core/trunk/WHATSNEW?rev=358828&r1=358827&r2=358828&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Dec 23 08:47:09 2005
@@ -333,6 +333,8 @@
* new GreedyInputHandler added.
+* add textfile attribute to the filesmatch condition.
+
Changes from Ant 1.6.4 to Ant 1.6.5
===================================
Modified: ant/core/trunk/docs/manual/CoreTasks/conditions.html
URL: http://svn.apache.org/viewcvs/ant/core/trunk/docs/manual/CoreTasks/conditions.html?rev=358828&r1=358827&r2=358828&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/conditions.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/conditions.html Fri Dec 23 08:47:09 2005
@@ -236,12 +236,19 @@
<tr>
<td valign="top">file1</td>
<td valign="top">First file to test</td>
- <td align="center">Yes.</td>
+ <td align="center">Yes</td>
</tr>
<tr>
<td valign="top">file2</td>
<td valign="top">Second file to test</td>
- <td align="center">Yes.</td>
+ <td align="center">Yes</td>
+ </tr>
+ <tr>
+ <td valign="top">textfile</td>
+ <td valign="top">Whether to ignore line endings when comparing files;
+ default <i>false</i>
+ </td>
+ <td align="center">No</td>
</tr>
</table>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/condition.xml
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/etc/testcases/taskdefs/condition.xml?rev=358828&r1=358827&r2=358828&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/condition.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/condition.xml Fri Dec 23 08:47:09 2005
@@ -196,9 +196,8 @@
file2="match2.txt" />
</condition>
<echo>${filesmatch-different}</echo>
- </target>
+ </target>
-
<target name="filesmatch-match" >
<echo file="match3.txt" message="012345676890" />
<echo file="match4.txt" message="012345676890" />
@@ -210,6 +209,32 @@
<echo>${filesmatch-match}</echo>
</target>
+ <target name="filesmatch-different-eol" >
+ <echo file="match7.txt" message="012345676890" />
+ <echo file="match8.txt" message="012345676890" />
+ <fixcrlf file="match7.txt" eol="cr" fixlast="true" />
+ <fixcrlf file="match8.txt" eol="lf" fixlast="true" />
+ <fail>
+ <condition>
+ <filesmatch file1="match7.txt" file2="match8.txt" />
+ </condition>
+ </fail>
+ </target>
+
+ <target name="filesmatch-same-eol" >
+ <echo file="match9.txt" message="012345676890" />
+ <echo file="match10.txt" message="012345676890" />
+ <fixcrlf file="match9.txt" eol="cr" fixlast="true" />
+ <fixcrlf file="match10.txt" eol="lf" fixlast="true" />
+ <fail>
+ <condition>
+ <not>
+ <filesmatch file1="match9.txt" file2="match10.txt" textfile="true" />
+ </not>
+ </condition>
+ </fail>
+ </target>
+
<target name="filesmatch-different-sizes">
<echo file="match5.txt" message="012345676890" />
<echo file="match6.txt" message="0123456768" />
@@ -374,12 +399,9 @@
</target>
<target name="cleanup" >
- <delete file="match1.txt" />
- <delete file="match2.txt" />
- <delete file="match3.txt" />
- <delete file="match4.txt" />
- <delete file="match5.txt" />
- <delete file="match6.txt" />
+ <delete>
+ <fileset dir="." includes="match?.txt,match??.txt" />
+ </delete>
</target>
</project>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java?rev=358828&r1=358827&r2=358828&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java Fri Dec 23 08:47:09 2005
@@ -22,7 +22,7 @@
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 @@
*/
private File file1, file2;
+ private boolean textfile = false;
+
/**
* Sets the File1 attribute
@@ -61,6 +63,14 @@
}
/**
+ * 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
*
* @return true if the files are equal
@@ -78,7 +88,7 @@
//#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);
Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java?rev=358828&r1=358827&r2=358828&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java (original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java Fri Dec 23 08:47:09 2005
@@ -162,6 +162,14 @@
"filesmatch-different-onemissing");
}
+ public void testFilesmatchDifferentEol() {
+ executeTarget("filesmatch-different-eol");
+ }
+
+ public void testFilesmatchSameEol() {
+ executeTarget("filesmatch-same-eol");
+ }
+
public void testContains() {
expectPropertySet("contains","contains");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org