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 5.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Apache Ant User Manual</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">Specifies the name of the property to be set
  51. with the generated checksum value. This cannot be specified
  52. when fileext is being used or when the number of files
  53. for which checksums is to be generated is greater than 1.
  54. </td>
  55. <td valign="top" align="center">No</td>
  56. </tr>
  57. <tr>
  58. <td valign="top">overwrite</td>
  59. <td valign="top">Overwrite existing files even if the destination
  60. files are newer. Defaults to &quot;no&quot;.</td>
  61. <td valign="top" align="center">No</td>
  62. </tr>
  63. <tr>
  64. <td valign="top">verifyproperty</td>
  65. <td valign="top">Specifies the name of the property to be set
  66. with &quot;true&quot; or &quot;false&quot; depending upon whether
  67. the generated checksum matches the existing checksum. When
  68. this is set, the generated checksum is not written to a file or
  69. property, but rather, the content of the file or property is used to
  70. check against the generated checksum.
  71. <td valign="top" align="center">No</td>
  72. </tr>
  73. </table>
  74. <h3>Parameters specified as nested elements</h3>
  75. <h4>fileset</h4>
  76. <p>
  77. <a href="../CoreTypes/fileset.html">FileSets</a> are used to select files to
  78. generate checksums for.
  79. </p>
  80. <h3>Examples</h3>
  81. <p><b>Example 1</b></p>
  82. <pre>&lt;checksum file=&quot;foo.bar&quot;/&gt;</pre>
  83. Generates a MD5 checksum for foo.bar and stores the checksum in the destination file
  84. foo.bar.MD5. foo.bar.MD5 is overwritten only if foo.bar is newer than itself.
  85. <p><b>Example 2</b></p>
  86. <pre>&lt;checksum file=&quot;foo.bar&quot; forceOverwrite=&quot;yes&quot;/&gt;</pre>
  87. Generates a MD5 checksum for foo.bar and stores the checksum in foo.bar.MD5.
  88. If foo.bar.MD5 already exists, it is overwritten.
  89. <p><b>Example 3</b></p>
  90. <pre>&lt;checksum file=&quot;foo.bar&quot; property=&quot;foobarMD5&quot;/&gt;</pre>
  91. Generates a MD5 checksum for foo.bar and stores it in the Project Property foobarMD5.
  92. <p><b>Example 4</b></p>
  93. <pre>&lt;checksum file=&quot;foo.bar&quot; verifyProperty=&quot;isMD5ok&quot;/&gt;</pre>
  94. Generates a MD5 checksum for foo.bar, compares it against foo.bar.MD5 and sets
  95. isMD5ok to either true or false, depending upon the result.
  96. <p><b>Example 5</b></p>
  97. <pre>&lt;checksum file=&quot;foo.bar&quot; algorithm=&quot;SHA&quot; fileext=&quot;asc&quot;/&gt;</pre>
  98. Generates a SHA checksum for foo.bar and stores the checksum in the destination file
  99. foo.bar.asc. foo.bar.asc is overwritten only if foo.bar is newer than itself.
  100. <p><b>Example 6</b></p>
  101. <pre>
  102. &lt;checksum file=&quot;foo.bar&quot; property=&quot;${md5}&quot; verifyProperty=&quot;isEqual&quot;/&gt;
  103. </pre>
  104. Generates a MD5 checksum for foo.bar, compares it against the value of the property
  105. md5, and sets isEqual to either true or false, depending upon the result.
  106. <p><b>Example 7</b></p>
  107. <pre>
  108. &lt;checksum&gt;
  109. &lt;fileset dir=&quot;.&quot;&gt;
  110. &lt;include name=&quot;foo*&quot;/&gt;
  111. &lt;/fileset&gt;
  112. &lt;/checksum&gt;
  113. </pre>
  114. Works just like Example 1, but generates a .MD5 file for every file that begins with the name foo.
  115. <p><b>Example 8</b></p>
  116. <pre>
  117. &lt;condition property=&quot;isChecksumEqual&quot;&gt;
  118. &lt;checksum&gt;
  119. &lt;fileset dir=&quot;.&quot;&gt;
  120. &lt;include name=&quot;foo.bar&quot;/&gt;
  121. &lt;/fileset&gt;
  122. &lt;/checksum&gt;
  123. &lt;/condition&gt;
  124. </pre>
  125. Works like Example 4, but only sets isChecksumEqual to true, if the
  126. checksum matches - it will never be set to false. This example
  127. demonstrates use with the Condition task.
  128. <h3>Note:</h3>
  129. When working with more than one file, if condition and/or verifyproperty is used,
  130. the result will be true only if the checksums matched correctly for all files being
  131. considered.
  132. <hr><p align="center">Copyright &copy; 2001 Apache Software Foundation. All rights
  133. Reserved.</p>
  134. </body>
  135. </html>