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.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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">algorithm</td>
  28. <td valign="top">Specifies the algorithm to be used to
  29. compute the checksum. Defaults to &quot;MD5&quot;.
  30. Other popular algorithms like &quot;SHA&quot; may be used
  31. as well.
  32. </td>
  33. <td valign="top" align="center">No</td>
  34. </tr>
  35. <tr>
  36. <td valign="top">provider</td>
  37. <td valign="top">Specifies the provider of the algorithm.</td>
  38. <td valign="top" align="center">No</td>
  39. </tr>
  40. <tr>
  41. <td valign="top">fileext</td>
  42. <td valign="top">The generated checksum file's name will be the
  43. original filename with &quot;.&quot; and fileext added to it.
  44. Defaults to the algorithm name being used.
  45. </td>
  46. <td valign="top" align="center">No</td>
  47. </tr>
  48. <tr>
  49. <td valign="top">property</td>
  50. <td valign="top">This attribute can mean two different things, it
  51. depends on the presence of the verifyproperty attribute.<br/>
  52. <b>If you don't set the verifyproperty attribute</b>, property
  53. specifies the name of the property to be set with the generated
  54. checksum value.<br/>
  55. <b>If you set the verifyproperty attribute</b>, property specifies
  56. the checksum you expect to be generated (the checksum itself, not
  57. a name of a property containing the checksum).<br/>
  58. This cannot be specified when fileext is being used or when the
  59. number of files for which checksums is to be generated is greater
  60. than 1.
  61. </td>
  62. <td valign="top" align="center">No</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">forceoverwrite</td>
  66. <td valign="top">Overwrite existing files even if the destination
  67. files are newer. Defaults to &quot;no&quot;.</td>
  68. <td valign="top" align="center">No</td>
  69. </tr>
  70. <tr>
  71. <td valign="top">verifyproperty</td>
  72. <td valign="top">Specifies the name of the property to be set
  73. with &quot;true&quot; or &quot;false&quot; depending upon whether
  74. the generated checksum matches the existing checksum. When
  75. this is set, the generated checksum is not written to a file or
  76. property, but rather, the content of the file or property is used to
  77. check against the generated checksum.
  78. <td valign="top" align="center">No</td>
  79. </tr>
  80. <tr>
  81. <td valign="top">readbuffersize</td>
  82. <td valign="top">The size of the buffer )in bytes) to use when
  83. reading a file. Defaults to &quot;8192&quot; - you may get a
  84. better performance on big files if you increase this value.</td>
  85. <td valign="top" align="center">No</td>
  86. </tr>
  87. </table>
  88. <h3>Parameters specified as nested elements</h3>
  89. <h4>fileset</h4>
  90. <p>
  91. <a href="../CoreTypes/fileset.html">FileSets</a> are used to select files to
  92. generate checksums for.
  93. </p>
  94. <h3>Examples</h3>
  95. <p><b>Example 1</b></p>
  96. <pre>&lt;checksum file=&quot;foo.bar&quot;/&gt;</pre>
  97. Generates a MD5 checksum for foo.bar and stores the checksum in the destination file
  98. foo.bar.MD5. foo.bar.MD5 is overwritten only if foo.bar is newer than itself.
  99. <p><b>Example 2</b></p>
  100. <pre>&lt;checksum file=&quot;foo.bar&quot; forceOverwrite=&quot;yes&quot;/&gt;</pre>
  101. Generates a MD5 checksum for foo.bar and stores the checksum in foo.bar.MD5.
  102. If foo.bar.MD5 already exists, it is overwritten.
  103. <p><b>Example 3</b></p>
  104. <pre>&lt;checksum file=&quot;foo.bar&quot; property=&quot;foobarMD5&quot;/&gt;</pre>
  105. Generates a MD5 checksum for foo.bar and stores it in the Project Property foobarMD5.
  106. <p><b>Example 4</b></p>
  107. <pre>&lt;checksum file=&quot;foo.bar&quot; verifyProperty=&quot;isMD5ok&quot;/&gt;</pre>
  108. Generates a MD5 checksum for foo.bar, compares it against foo.bar.MD5 and sets
  109. isMD5ok to either true or false, depending upon the result.
  110. <p><b>Example 5</b></p>
  111. <pre>&lt;checksum file=&quot;foo.bar&quot; algorithm=&quot;SHA&quot; fileext=&quot;asc&quot;/&gt;</pre>
  112. Generates a SHA checksum for foo.bar and stores the checksum in the destination file
  113. foo.bar.asc. foo.bar.asc is overwritten only if foo.bar is newer than itself.
  114. <p><b>Example 6</b></p>
  115. <pre>
  116. &lt;checksum file=&quot;foo.bar&quot; property=&quot;${md5}&quot; verifyProperty=&quot;isEqual&quot;/&gt;
  117. </pre>
  118. Generates a MD5 checksum for foo.bar, compares it against the value of the property
  119. md5, and sets isEqual to either true or false, depending upon the result.
  120. <p><b>Example 7</b></p>
  121. <pre>
  122. &lt;checksum&gt;
  123. &lt;fileset dir=&quot;.&quot;&gt;
  124. &lt;include name=&quot;foo*&quot;/&gt;
  125. &lt;/fileset&gt;
  126. &lt;/checksum&gt;
  127. </pre>
  128. Works just like Example 1, but generates a .MD5 file for every file that begins with the name foo.
  129. <p><b>Example 8</b></p>
  130. <pre>
  131. &lt;condition property=&quot;isChecksumEqual&quot;&gt;
  132. &lt;checksum&gt;
  133. &lt;fileset dir=&quot;.&quot;&gt;
  134. &lt;include name=&quot;foo.bar&quot;/&gt;
  135. &lt;/fileset&gt;
  136. &lt;/checksum&gt;
  137. &lt;/condition&gt;
  138. </pre>
  139. Works like Example 4, but only sets isChecksumEqual to true, if the
  140. checksum matches - it will never be set to false. This example
  141. demonstrates use with the Condition task.
  142. <h3>Note:</h3>
  143. When working with more than one file, if condition and/or verifyproperty is used,
  144. the result will be true only if the checksums matched correctly for all files being
  145. considered.
  146. <hr><p align="center">Copyright &copy; 2001-2003 Apache Software Foundation. All rights
  147. Reserved.</p>
  148. </body>
  149. </html>