git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1027103 13f79535-47bb-0310-9956-ffa450edef68master
@@ -232,6 +232,10 @@ Other changes: | |||||
* <javah> now supports the GNU project's gcjh compiler. | * <javah> now supports the GNU project's gcjh compiler. | ||||
Bugzilla Report 50149. | 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 | Changes from Ant 1.8.0 TO Ant 1.8.1 | ||||
=================================== | =================================== | ||||
@@ -113,10 +113,16 @@ or set the <tt>fileext</tt> attribute. | |||||
<tr> | <tr> | ||||
<td valign="top">pattern</td> | <td valign="top">pattern</td> | ||||
<td valign="top">Specifies the pattern to use as a pattern | <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 | 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> | <td valign="top" align="center">No - default is "{0}".</td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
@@ -61,6 +61,7 @@ import org.apache.tools.ant.util.StringUtils; | |||||
*/ | */ | ||||
public class Checksum extends MatchingTask implements Condition { | 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 NIBBLE = 4; | ||||
private static final int WORD = 16; | private static final int WORD = 16; | ||||
private static final int BUFFER_SIZE = 8 * 1024; | private static final int BUFFER_SIZE = 8 * 1024; | ||||
@@ -531,6 +532,15 @@ public class Checksum extends MatchingTask implements Condition { | |||||
fos.write(format.format(new Object[] { | fos.write(format.format(new Object[] { | ||||
checksum, | checksum, | ||||
src.getName(), | src.getName(), | ||||
FILE_UTILS | |||||
.getRelativePath(dest | |||||
.getParentFile(), | |||||
src), | |||||
FILE_UTILS | |||||
.getRelativePath(getProject() | |||||
.getBaseDir(), | |||||
src), | |||||
src.getAbsolutePath() | |||||
}).getBytes()); | }).getBytes()); | ||||
fos.write(StringUtils.LINE_SEP.getBytes()); | fos.write(StringUtils.LINE_SEP.getBytes()); | ||||
fos.close(); | fos.close(); | ||||
@@ -45,4 +45,39 @@ | |||||
value="f4d688789d32e6ca6bc93c504dbc6b46"/> | value="f4d688789d32e6ca6bc93c504dbc6b46"/> | ||||
</target> | </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> | </project> |