antoine 2004/07/17 09:08:41 Modified: . WHATSNEW docs/manual/CoreTypes selectors.html src/main/org/apache/tools/ant/types/selectors DifferentSelector.java Log: Added an ignorecontents attribute to <different> Revision Changes Path 1.639 +2 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.638 retrieving revision 1.639 diff -u -r1.638 -r1.639 --- WHATSNEW 17 Jul 2004 15:10:10 -0000 1.638 +++ WHATSNEW 17 Jul 2004 16:08:41 -0000 1.639 @@ -37,6 +37,8 @@ Other changes: -------------- +* New attribute ignorecontents for <different> selector + Fixed bugs: ----------- 1.25 +10 -1 ant/docs/manual/CoreTypes/selectors.html Index: selectors.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTypes/selectors.html,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- selectors.html 12 Jul 2004 15:04:13 -0000 1.24 +++ selectors.html 17 Jul 2004 16:08:41 -0000 1.25 @@ -300,7 +300,8 @@ <li> Files with different lengths are different. <li> If <tt>ignoreFileTimes</tt> is turned off, then differing file timestamps will cause files to be regarded as different. - <li> Finally a byte-for-byte check is run against the two files + <li> Unless<tt>ignoreContents</tt> is set to true, a byte-for-byte check is run + against the two files </ol> This is a useful selector to work with programs and tasks that don't handle @@ -339,6 +340,14 @@ <td valign="top">ignoreFileTimes</td> <td valign="top">Whether to use file times in the comparison or not. Default is true (time differences are ignored). + </td> + <td valign="top" align="center">No</td> + </tr> + <tr> + <td valign="top">ignoreContents</td> + <td valign="top">Whether to do a byte per byte compare. + Default is false (contents are compared). + Since ant 1.6.3 </td> <td valign="top" align="center">No</td> </tr> 1.13 +26 -11 ant/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java Index: DifferentSelector.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- DifferentSelector.java 9 Mar 2004 16:48:47 -0000 1.12 +++ DifferentSelector.java 17 Jul 2004 16:08:41 -0000 1.13 @@ -25,10 +25,14 @@ /** * This selector selects files against a mapped set of target files, selecting - * all those files which are different. A byte-by-byte comparision is performed - * on equal length files; files with different lengths are deemed different - * automatically; files with identical timestamps are viewed as matching by + * all those files which are different. + * Files with different lengths are deemed different + * automatically + * Files with identical timestamps are viewed as matching by * default, unless you specify otherwise. + * Contents are compared if the lengths are the same + * and the timestamps are ignored or the same, + * except if you decide to ignore contents to gain speed. * <p> * This is a useful selector to work with programs and tasks that don't handle * dependency checking properly; Even if a predecessor task always creates its @@ -47,6 +51,7 @@ private FileUtils fileUtils = FileUtils.newFileUtils(); private boolean ignoreFileTimes = true; + private boolean ignoreContents = false; /** @@ -56,7 +61,14 @@ public void setIgnoreFileTimes(boolean ignoreFileTimes) { this.ignoreFileTimes = ignoreFileTimes; } - + /** + * This flag tells the selector to ignore contents + * @param ignoreContents if true ignore contents + * @since ant 1.6.3 + */ + public void setIgnoreContents(boolean ignoreContents) { + this.ignoreContents = ignoreContents; + } /** * this test is our selection test that compared the file with the destfile * @param srcfile the source file @@ -86,13 +98,16 @@ return true; } } - - //here do a bulk comparison - try { - return !fileUtils.contentEquals(srcfile, destfile); - } catch (IOException e) { - throw new BuildException("while comparing " + srcfile + " and " - + destfile, e); + if (!ignoreContents) { + //here do a bulk comparison + try { + return !fileUtils.contentEquals(srcfile, destfile); + } catch (IOException e) { + throw new BuildException("while comparing " + srcfile + " and " + + destfile, e); + } + } else { + return false; } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]