You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2010/10/25 15:12:33 UTC
svn commit: r1027103 - in /ant/core/trunk: WHATSNEW
docs/manual/Tasks/checksum.html
src/main/org/apache/tools/ant/taskdefs/Checksum.java
src/tests/antunit/taskdefs/checksum-test.xml
Author: bodewig
Date: Mon Oct 25 13:12:33 2010
New Revision: 1027103
URL: http://svn.apache.org/viewvc?rev=1027103&view=rev
Log:
allow more path 'views' of a file as elements inside <checksum>s pattern. PR 50114
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/docs/manual/Tasks/checksum.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java
ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1027103&r1=1027102&r2=1027103&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Oct 25 13:12:33 2010
@@ -232,6 +232,10 @@ Other changes:
* <javah> now supports the GNU project's gcjh compiler.
Bugzilla Report 50149.
+ * <checksum> supports additional views of a file's path as elements
+ for a custom pattern.
+ Bugzilla Report 50114.
+
Changes from Ant 1.8.0 TO Ant 1.8.1
===================================
Modified: ant/core/trunk/docs/manual/Tasks/checksum.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/Tasks/checksum.html?rev=1027103&r1=1027102&r2=1027103&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/Tasks/checksum.html (original)
+++ ant/core/trunk/docs/manual/Tasks/checksum.html Mon Oct 25 13:12:33 2010
@@ -113,10 +113,16 @@ or set the <tt>fileext</tt> attribute.
<tr>
<td valign="top">pattern</td>
<td valign="top">Specifies the pattern to use as a pattern
- suitable for <a
- href="http://download.oracle.com/javase/6/docs/api/java/text/MessageFormat.html">MessageFormat</a>
+ suitable
+ for <a href="http://download.oracle.com/javase/6/docs/api/java/text/MessageFormat.html">MessageFormat</a>
where <code>{0}</code> is replaced with the checksum and
- <code>{1}</code> with the file name. <em>Since Ant 1.7.0</em></td>
+ <code>{1}</code> with the file name. <em>Since Ant
+ 1.7.0</em><br/>
+ <em>starting with Ant 1.8.2</em> <code>{2}</code> is replaced by
+ the path of the file relative to the checksum file being
+ written, <code>{3}</code> with tha path of the file relative to
+ the project's basedir and <code>{4}</code> with the absolute
+ path of the file.</td>
<td valign="top" align="center">No - default is "{0}".</td>
</tr>
<tr>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java?rev=1027103&r1=1027102&r2=1027103&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java Mon Oct 25 13:12:33 2010
@@ -61,6 +61,7 @@ import org.apache.tools.ant.util.StringU
*/
public class Checksum extends MatchingTask implements Condition {
+ private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
private static final int NIBBLE = 4;
private static final int WORD = 16;
private static final int BUFFER_SIZE = 8 * 1024;
@@ -531,6 +532,15 @@ public class Checksum extends MatchingTa
fos.write(format.format(new Object[] {
checksum,
src.getName(),
+ FILE_UTILS
+ .getRelativePath(dest
+ .getParentFile(),
+ src),
+ FILE_UTILS
+ .getRelativePath(getProject()
+ .getBaseDir(),
+ src),
+ src.getAbsolutePath()
}).getBytes());
fos.write(StringUtils.LINE_SEP.getBytes());
fos.close();
Modified: ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml?rev=1027103&r1=1027102&r2=1027103&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml Mon Oct 25 13:12:33 2010
@@ -45,4 +45,39 @@
value="f4d688789d32e6ca6bc93c504dbc6b46"/>
</target>
+ <target name="testChecksumPattern2">
+ <mkdir dir="${output}"/>
+ <mkdir dir="${input}"/>
+ <echo file="${input}/a.txt">abc</echo>
+ <checksum todir="${output}" pattern="{2}">
+ <fileset dir="${input}"/>
+ </checksum>
+ <au:assertResourceContains
+ resource="${output}/a.txt.MD5"
+ value="../testinput/a.txt"/>
+ </target>
+
+ <target name="testChecksumPattern3">
+ <mkdir dir="${output}"/>
+ <checksum todir="${output}" pattern="{3}">
+ <fileset dir=".." includes="types/fileset-test.xml"/>
+ </checksum>
+ <au:assertResourceContains
+ resource="${output}/types/fileset-test.xml.MD5"
+ value="../types/fileset-test.xml"/>
+ </target>
+
+ <target name="testChecksumPattern4">
+ <mkdir dir="${output}"/>
+ <mkdir dir="${input}"/>
+ <property name="a" location="${input}/a.txt"/>
+ <echo file="${a}">abc</echo>
+ <checksum todir="${output}" pattern="{4}">
+ <fileset dir="${input}"/>
+ </checksum>
+ <au:assertResourceContains
+ resource="${output}/a.txt.MD5"
+ value="${a}"/>
+ </target>
+
</project>