2001-11-16 12:30:58 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
2002-02-03 22:00:42 +00:00
|
|
|
<title>Checksum Task</title>
|
2001-11-16 12:30:58 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h2><a name="checksum">Checksum</a></h2>
|
|
|
|
<h3>Description</h3>
|
|
|
|
<p>
|
|
|
|
Generates checksum for files. This task can also be used to
|
|
|
|
perform checksum verifications.
|
|
|
|
</p>
|
|
|
|
<h3>Parameters</h3>
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td valign="top"><b>Attribute</b></td>
|
|
|
|
<td valign="top"><b>Description</b></td>
|
|
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">file</td>
|
|
|
|
<td valign="top">The file to generate checksum for.</td>
|
|
|
|
<td valign="top" align="center">One of either <var>file</var> or
|
|
|
|
at least one nested fileset element.</td>
|
|
|
|
</tr>
|
2003-06-24 15:06:12 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">todir</td>
|
|
|
|
<td valign="top">The root directory where checksums should be written.</td>
|
|
|
|
<td valign="top" align="center">No. If not specified, checksum files
|
|
|
|
will be written to the same directory as the files themselves.
|
2003-06-24 15:28:23 +00:00
|
|
|
<em>since Ant 1.6</em>
|
2003-06-24 15:06:12 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2001-11-16 12:30:58 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">algorithm</td>
|
|
|
|
<td valign="top">Specifies the algorithm to be used to
|
|
|
|
compute the checksum. Defaults to "MD5".
|
|
|
|
Other popular algorithms like "SHA" may be used
|
|
|
|
as well.
|
|
|
|
</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">provider</td>
|
|
|
|
<td valign="top">Specifies the provider of the algorithm.</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">fileext</td>
|
|
|
|
<td valign="top">The generated checksum file's name will be the
|
2004-08-23 14:15:06 +00:00
|
|
|
original filename with the fileext added to it.
|
|
|
|
Defaults to a "." and the algorithm name being used.
|
2001-11-16 12:30:58 +00:00
|
|
|
</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">property</td>
|
2003-04-09 14:31:47 +00:00
|
|
|
<td valign="top">This attribute can mean two different things, it
|
|
|
|
depends on the presence of the verifyproperty attribute.<br/>
|
|
|
|
<b>If you don't set the verifyproperty attribute</b>, property
|
|
|
|
specifies the name of the property to be set with the generated
|
|
|
|
checksum value.<br/>
|
|
|
|
<b>If you set the verifyproperty attribute</b>, property specifies
|
|
|
|
the checksum you expect to be generated (the checksum itself, not
|
|
|
|
a name of a property containing the checksum).<br/>
|
|
|
|
This cannot be specified when fileext is being used or when the
|
|
|
|
number of files for which checksums is to be generated is greater
|
|
|
|
than 1.
|
2001-11-16 12:30:58 +00:00
|
|
|
</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
2004-09-10 14:19:26 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">pattern</td>
|
|
|
|
<td valign="top">Specifies the pattern to use as a pattern
|
|
|
|
suitable for <a
|
|
|
|
href="http://java.sun.com/j2se/1.4.2/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.</td>
|
|
|
|
<td valign="top" align="center">No - default is "{0}".</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">format</td>
|
|
|
|
<td valign="top">Specifies the pattern to use as one of a
|
|
|
|
well-known format. Supported values are "CHECKSUM"
|
|
|
|
(only the checksum itself, the default), "MD5SUM" the
|
|
|
|
format of GNU textutils md5sum and "SVF" the format of
|
|
|
|
*BSDs md5 command.</td>
|
|
|
|
<td valign="top" align="center">No - default is "CHECKSUM".</td>
|
|
|
|
</tr>
|
2003-06-24 15:06:12 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">totalproperty</td>
|
|
|
|
<td valign="top">If specified, this attribute specifies the name of
|
|
|
|
the property that will hold a checksum of all the checksums and
|
|
|
|
file paths. The individual checksums and the relative paths to
|
|
|
|
the files within the filesets they are defined in will be used to
|
|
|
|
compute this checksum. (The file separators in the paths will be
|
|
|
|
converted to '/' before computation to ensure platform portability).
|
2003-06-24 15:28:23 +00:00
|
|
|
<em>since Ant 1.6</em>
|
2003-06-24 15:06:12 +00:00
|
|
|
</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
2001-11-16 12:30:58 +00:00
|
|
|
<tr>
|
2002-06-22 23:38:38 +00:00
|
|
|
<td valign="top">forceoverwrite</td>
|
2001-11-16 12:30:58 +00:00
|
|
|
<td valign="top">Overwrite existing files even if the destination
|
|
|
|
files are newer. Defaults to "no".</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">verifyproperty</td>
|
|
|
|
<td valign="top">Specifies the name of the property to be set
|
|
|
|
with "true" or "false" depending upon whether
|
|
|
|
the generated checksum matches the existing checksum. When
|
|
|
|
this is set, the generated checksum is not written to a file or
|
|
|
|
property, but rather, the content of the file or property is used to
|
|
|
|
check against the generated checksum.
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
2002-06-22 23:38:38 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">readbuffersize</td>
|
2004-01-05 10:52:06 +00:00
|
|
|
<td valign="top">The size of the buffer (in bytes) to use when
|
2002-06-22 23:38:38 +00:00
|
|
|
reading a file. Defaults to "8192" - you may get a
|
|
|
|
better performance on big files if you increase this value.</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
2001-11-16 12:30:58 +00:00
|
|
|
</table>
|
|
|
|
<h3>Parameters specified as nested elements</h3>
|
|
|
|
|
|
|
|
<h4>fileset</h4>
|
|
|
|
<p>
|
|
|
|
<a href="../CoreTypes/fileset.html">FileSets</a> are used to select files to
|
|
|
|
generate checksums for.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<h3>Examples</h3>
|
|
|
|
<p><b>Example 1</b></p>
|
|
|
|
<pre><checksum file="foo.bar"/></pre>
|
|
|
|
Generates a MD5 checksum for foo.bar and stores the checksum in the destination file
|
|
|
|
foo.bar.MD5. foo.bar.MD5 is overwritten only if foo.bar is newer than itself.
|
|
|
|
|
|
|
|
<p><b>Example 2</b></p>
|
|
|
|
<pre><checksum file="foo.bar" forceOverwrite="yes"/></pre>
|
|
|
|
Generates a MD5 checksum for foo.bar and stores the checksum in foo.bar.MD5.
|
|
|
|
If foo.bar.MD5 already exists, it is overwritten.
|
|
|
|
|
|
|
|
<p><b>Example 3</b></p>
|
|
|
|
<pre><checksum file="foo.bar" property="foobarMD5"/></pre>
|
|
|
|
Generates a MD5 checksum for foo.bar and stores it in the Project Property foobarMD5.
|
|
|
|
|
|
|
|
<p><b>Example 4</b></p>
|
|
|
|
<pre><checksum file="foo.bar" verifyProperty="isMD5ok"/></pre>
|
|
|
|
Generates a MD5 checksum for foo.bar, compares it against foo.bar.MD5 and sets
|
|
|
|
isMD5ok to either true or false, depending upon the result.
|
|
|
|
|
|
|
|
<p><b>Example 5</b></p>
|
|
|
|
<pre><checksum file="foo.bar" algorithm="SHA" fileext="asc"/></pre>
|
|
|
|
Generates a SHA checksum for foo.bar and stores the checksum in the destination file
|
|
|
|
foo.bar.asc. foo.bar.asc is overwritten only if foo.bar is newer than itself.
|
|
|
|
|
|
|
|
<p><b>Example 6</b></p>
|
|
|
|
<pre>
|
|
|
|
<checksum file="foo.bar" property="${md5}" verifyProperty="isEqual"/>
|
|
|
|
</pre>
|
|
|
|
Generates a MD5 checksum for foo.bar, compares it against the value of the property
|
|
|
|
md5, and sets isEqual to either true or false, depending upon the result.
|
|
|
|
|
|
|
|
<p><b>Example 7</b></p>
|
|
|
|
<pre>
|
|
|
|
<checksum>
|
|
|
|
<fileset dir=".">
|
|
|
|
<include name="foo*"/>
|
|
|
|
</fileset>
|
|
|
|
</checksum>
|
|
|
|
</pre>
|
|
|
|
Works just like Example 1, but generates a .MD5 file for every file that begins with the name foo.
|
|
|
|
|
|
|
|
<p><b>Example 8</b></p>
|
|
|
|
<pre>
|
|
|
|
<condition property="isChecksumEqual">
|
|
|
|
<checksum>
|
|
|
|
<fileset dir=".">
|
|
|
|
<include name="foo.bar"/>
|
|
|
|
</fileset>
|
|
|
|
</checksum>
|
|
|
|
</condition>
|
|
|
|
</pre>
|
2001-11-19 15:18:46 +00:00
|
|
|
Works like Example 4, but only sets isChecksumEqual to true, if the
|
|
|
|
checksum matches - it will never be set to false. This example
|
|
|
|
demonstrates use with the Condition task.
|
2001-11-16 12:30:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
<h3>Note:</h3>
|
|
|
|
When working with more than one file, if condition and/or verifyproperty is used,
|
|
|
|
the result will be true only if the checksums matched correctly for all files being
|
|
|
|
considered.
|
|
|
|
|
2004-02-09 21:50:10 +00:00
|
|
|
<hr><p align="center">Copyright © 2001-2004 The Apache Software Foundation. All rights
|
2001-11-16 12:30:58 +00:00
|
|
|
Reserved.</p>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|