You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

checksum.html 6.8 kB

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