source: release-kits/lirk3/bin/ant-installer/web/manual1.6.2/manual/CoreTasks/checksum.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 6.8 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Checksum Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="checksum">Checksum</a></h2>
12<h3>Description</h3>
13<p>
14Generates checksum for files. This task can also be used to
15perform checksum verifications.
16</p>
17<h3>Parameters</h3>
18<table border="1" cellpadding="2" cellspacing="0">
19 <tr>
20 <td valign="top"><b>Attribute</b></td>
21 <td valign="top"><b>Description</b></td>
22 <td align="center" valign="top"><b>Required</b></td>
23 </tr>
24 <tr>
25 <td valign="top">file</td>
26 <td valign="top">The file to generate checksum for.</td>
27 <td valign="top" align="center">One of either <var>file</var> or
28 at least one nested fileset element.</td>
29 </tr>
30 <tr>
31 <td valign="top">todir</td>
32 <td valign="top">The root directory where checksums should be written.</td>
33 <td valign="top" align="center">No. If not specified, checksum files
34 will be written to the same directory as the files themselves.
35 <em>since Ant 1.6</em>
36 </td>
37 </tr>
38 <tr>
39 <td valign="top">algorithm</td>
40 <td valign="top">Specifies the algorithm to be used to
41 compute the checksum. Defaults to &quot;MD5&quot;.
42 Other popular algorithms like &quot;SHA&quot; may be used
43 as well.
44 </td>
45 <td valign="top" align="center">No</td>
46 </tr>
47 <tr>
48 <td valign="top">provider</td>
49 <td valign="top">Specifies the provider of the algorithm.</td>
50 <td valign="top" align="center">No</td>
51 </tr>
52 <tr>
53 <td valign="top">fileext</td>
54 <td valign="top">The generated checksum file's name will be the
55 original filename with &quot;.&quot; and fileext added to it.
56 Defaults to the algorithm name being used.
57 </td>
58 <td valign="top" align="center">No</td>
59 </tr>
60 <tr>
61 <td valign="top">property</td>
62 <td valign="top">This attribute can mean two different things, it
63 depends on the presence of the verifyproperty attribute.<br/>
64 <b>If you don't set the verifyproperty attribute</b>, property
65 specifies the name of the property to be set with the generated
66 checksum value.<br/>
67 <b>If you set the verifyproperty attribute</b>, property specifies
68 the checksum you expect to be generated (the checksum itself, not
69 a name of a property containing the checksum).<br/>
70 This cannot be specified when fileext is being used or when the
71 number of files for which checksums is to be generated is greater
72 than 1.
73 </td>
74 <td valign="top" align="center">No</td>
75 </tr>
76 <tr>
77 <td valign="top">totalproperty</td>
78 <td valign="top">If specified, this attribute specifies the name of
79 the property that will hold a checksum of all the checksums and
80 file paths. The individual checksums and the relative paths to
81 the files within the filesets they are defined in will be used to
82 compute this checksum. (The file separators in the paths will be
83 converted to '/' before computation to ensure platform portability).
84 <em>since Ant 1.6</em>
85 </td>
86 <td valign="top" align="center">No</td>
87 </tr>
88 <tr>
89 <td valign="top">forceoverwrite</td>
90 <td valign="top">Overwrite existing files even if the destination
91 files are newer. Defaults to &quot;no&quot;.</td>
92 <td valign="top" align="center">No</td>
93 </tr>
94 <tr>
95 <td valign="top">verifyproperty</td>
96 <td valign="top">Specifies the name of the property to be set
97 with &quot;true&quot; or &quot;false&quot; depending upon whether
98 the generated checksum matches the existing checksum. When
99 this is set, the generated checksum is not written to a file or
100 property, but rather, the content of the file or property is used to
101 check against the generated checksum.
102 <td valign="top" align="center">No</td>
103 </tr>
104 <tr>
105 <td valign="top">readbuffersize</td>
106 <td valign="top">The size of the buffer (in bytes) to use when
107 reading a file. Defaults to &quot;8192&quot; - you may get a
108 better performance on big files if you increase this value.</td>
109 <td valign="top" align="center">No</td>
110 </tr>
111</table>
112<h3>Parameters specified as nested elements</h3>
113
114<h4>fileset</h4>
115 <p>
116 <a href="../CoreTypes/fileset.html">FileSets</a> are used to select files to
117 generate checksums for.
118 </p>
119
120<h3>Examples</h3>
121<p><b>Example 1</b></p>
122<pre>&lt;checksum file=&quot;foo.bar&quot;/&gt;</pre>
123Generates a MD5 checksum for foo.bar and stores the checksum in the destination file
124foo.bar.MD5. foo.bar.MD5 is overwritten only if foo.bar is newer than itself.
125
126<p><b>Example 2</b></p>
127<pre>&lt;checksum file=&quot;foo.bar&quot; forceOverwrite=&quot;yes&quot;/&gt;</pre>
128Generates a MD5 checksum for foo.bar and stores the checksum in foo.bar.MD5.
129If foo.bar.MD5 already exists, it is overwritten.
130
131<p><b>Example 3</b></p>
132<pre>&lt;checksum file=&quot;foo.bar&quot; property=&quot;foobarMD5&quot;/&gt;</pre>
133Generates a MD5 checksum for foo.bar and stores it in the Project Property foobarMD5.
134
135<p><b>Example 4</b></p>
136<pre>&lt;checksum file=&quot;foo.bar&quot; verifyProperty=&quot;isMD5ok&quot;/&gt;</pre>
137Generates a MD5 checksum for foo.bar, compares it against foo.bar.MD5 and sets
138isMD5ok to either true or false, depending upon the result.
139
140<p><b>Example 5</b></p>
141<pre>&lt;checksum file=&quot;foo.bar&quot; algorithm=&quot;SHA&quot; fileext=&quot;asc&quot;/&gt;</pre>
142Generates a SHA checksum for foo.bar and stores the checksum in the destination file
143foo.bar.asc. foo.bar.asc is overwritten only if foo.bar is newer than itself.
144
145<p><b>Example 6</b></p>
146<pre>
147&lt;checksum file=&quot;foo.bar&quot; property=&quot;${md5}&quot; verifyProperty=&quot;isEqual&quot;/&gt;
148</pre>
149Generates a MD5 checksum for foo.bar, compares it against the value of the property
150md5, and sets isEqual to either true or false, depending upon the result.
151
152<p><b>Example 7</b></p>
153<pre>
154&lt;checksum&gt;
155 &lt;fileset dir=&quot;.&quot;&gt;
156 &lt;include name=&quot;foo*&quot;/&gt;
157 &lt;/fileset&gt;
158&lt;/checksum&gt;
159</pre>
160Works just like Example 1, but generates a .MD5 file for every file that begins with the name foo.
161
162<p><b>Example 8</b></p>
163<pre>
164&lt;condition property=&quot;isChecksumEqual&quot;&gt;
165 &lt;checksum&gt;
166 &lt;fileset dir=&quot;.&quot;&gt;
167 &lt;include name=&quot;foo.bar&quot;/&gt;
168 &lt;/fileset&gt;
169 &lt;/checksum&gt;
170&lt;/condition&gt;
171</pre>
172Works like Example 4, but only sets isChecksumEqual to true, if the
173checksum matches - it will never be set to false. This example
174demonstrates use with the Condition task.
175
176
177<h3>Note:</h3>
178When working with more than one file, if condition and/or verifyproperty is used,
179the result will be true only if the checksums matched correctly for all files being
180considered.
181
182<hr><p align="center">Copyright &copy; 2001-2004 The Apache Software Foundation. All rights
183Reserved.</p>
184
185</body>
186</html>
187
Note: See TracBrowser for help on using the repository browser.