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.

tar.html 7.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="tar">Tar</a></h2>
  8. <h3>Description</h3>
  9. <p>Creates a tar archive.</p>
  10. <p>The <i>basedir</i> attribute is the reference directory from where to tar.</p>
  11. <p>This task is a <a href="../dirtasks.html#directorybasedtasks">directory based task</a>
  12. and, as such, forms an implicit <a href="../CoreTypes/fileset.html">Fileset</a>. This
  13. defines which files, relative to the <i>basedir</i>, will be included in the
  14. archive. The tar task supports all the attributes of Fileset to refine the
  15. set of files to be included in the implicit fileset.</p>
  16. <p>In addition to the implicit fileset, the tar task supports nested filesets. These
  17. filesets are extended to allow control over the access mode, username and groupname
  18. to be applied to the tar entries. This is useful, for example, when preparing archives for
  19. Unix systems where some files need to have execute permission.</p>
  20. <p>The POSIX tar standard does not support path lengths greater than 100 characters. The
  21. behaviour of the tar task when it encounters such paths is controlled by the <i>longfile</i>
  22. attribute. If this attribute is not present, the tar task will throw an exception upon encountering
  23. a long path. If the longfile attribute is set to <code>truncate</code>, any long paths will be
  24. truncated to the 100 character maximum length prior to adding to the archive. This ensures that
  25. the file will be in the archive and that the archive can be untarred by any compliant version of
  26. tar. If the loss of path information is not acceptable, and it rarely is, longfile may be set to
  27. the value <code>gnu</code>. The tar task will then produce a GNU tar file which can have
  28. arbitrary length paths. Note however, that the resulting archive will only be able to be untarred
  29. with GNU tar.</p>
  30. <p>Note that this task does not perform compression. You might want to use the
  31. <a href="gzip.html">GZip</a> task to prepare a .tar.gz package.</p>
  32. <h3>Parameters</h3>
  33. <table border="1" cellpadding="2" cellspacing="0">
  34. <tr>
  35. <td valign="top"><b>Attribute</b></td>
  36. <td valign="top"><b>Description</b></td>
  37. <td valign="top" align="center"><b>Required</b></td>
  38. </tr>
  39. <tr>
  40. <td valign="top">tarfile</td>
  41. <td valign="top">the tar-file to create.</td>
  42. <td align="center" valign="top">Yes</td>
  43. </tr>
  44. <tr>
  45. <td valign="top">basedir</td>
  46. <td valign="top">the directory from which to zip the files.</td>
  47. <td align="center" valign="top">No</td>
  48. </tr>
  49. <tr>
  50. <td valign="top">longfile</td>
  51. <td valign="top">Controls how long paths are handled. Allowable
  52. values are &quot;gnu&quot; and &quot;truncate&quot;</td>
  53. <td align="center" valign="top">No</td>
  54. </tr>
  55. <tr>
  56. <td valign="top">includes</td>
  57. <td valign="top">comma separated list of patterns of files that must be
  58. included. All files are included when omitted.</td>
  59. <td valign="top" align="center">No</td>
  60. </tr>
  61. <tr>
  62. <td valign="top">includesfile</td>
  63. <td valign="top">the name of a file. Each line of this file is
  64. taken to be an include pattern</td>
  65. <td valign="top" align="center">No</td>
  66. </tr>
  67. <tr>
  68. <td valign="top">excludes</td>
  69. <td valign="top">comma separated list of patterns of files that must be
  70. excluded. No files (except default excludes) are excluded when omitted.</td>
  71. <td valign="top" align="center">No</td>
  72. </tr>
  73. <tr>
  74. <td valign="top">excludesfile</td>
  75. <td valign="top">the name of a file. Each line of this file is
  76. taken to be an exclude pattern</td>
  77. <td valign="top" align="center">No</td>
  78. </tr>
  79. <tr>
  80. <td valign="top">defaultexcludes</td>
  81. <td valign="top">indicates whether default excludes should be used or not
  82. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  83. <td valign="top" align="center">No</td>
  84. </tr>
  85. </table>
  86. <h3>Nested Elements</h3>
  87. The tar task supports nested <a href="../CoreTypes/fileset.html">tarfileset</a> elements. These are
  88. extended Filesets which, in addition to the standard fileset elements, support three additional
  89. attributes
  90. <table border="1" cellpadding="2" cellspacing="0">
  91. <tr>
  92. <td valign="top"><b>Attribute</b></td>
  93. <td valign="top"><b>Description</b></td>
  94. <td valign="top" align="center"><b>Required</b></td>
  95. </tr>
  96. <tr>
  97. <td valign="top">mode</td>
  98. <td valign="top">An 3 digit octal string, specify the user, group and other modes in
  99. the standard Unix fashion</td>
  100. <td align="center" valign="top">No</td>
  101. </tr>
  102. <tr>
  103. <td valign="top">username</td>
  104. <td valign="top">The username for the tar entry. This is not the same as the UID, which is
  105. not currently set by the tar task.</td>
  106. <td align="center" valign="top">No</td>
  107. </tr>
  108. <tr>
  109. <td valign="top">groupname</td>
  110. <td valign="top">The username for the tar entry. This is not the same as the GID, which is
  111. not currently set by the tar task.</td>
  112. <td align="center" valign="top">No</td>
  113. </tr>
  114. </table>
  115. <h3>Examples</h3>
  116. <pre> &lt;tar tarfile=&quot;${dist}/manual.tar&quot; basedir=&quot;htdocs/manual&quot;/&gt;
  117. &lt;gzip zipfile=&quot;${dist}/manual.tar.gz&quot; src=&quot;${dist}/manual.tar&quot;/&gt;</pre>
  118. <p>tars all files in the <code>htdocs/manual</code> directory into a file called <code>manual.tar</code>
  119. in the <code>${dist}</code> directory, then applies the gzip task to compress
  120. it.</p>
  121. <pre> &lt;tar tarfile=&quot;${dist}/manual.tar&quot;
  122. basedir=&quot;htdocs/manual&quot;
  123. excludes=&quot;mydocs/**, **/todo.html&quot;
  124. /&gt;</pre>
  125. <p>tars all files in the <code>htdocs/manual</code> directory into a file called <code>manual.tar</code>
  126. in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>,
  127. or files with the name <code>todo.html</code> are excluded.</p>
  128. <pre>&lt;tar longfile=&quot;gnu&quot;
  129. tarfile=&quot;${dist.base}/${dist.name}-src.tar&quot; &gt;
  130. &lt;tarfileset dir=&quot;${dist.name}/..&quot; mode=&quot;755&quot; username=&quot;ant&quot; group=&quot;ant&quot;&gt;
  131. &lt;include name=&quot;${dist.name}/bootstrap.sh&quot;/&gt;
  132. &lt;include name=&quot;${dist.name}/build.sh&quot;/&gt;
  133. &lt;/fileset&gt;
  134. &lt;tarfileset dir=&quot;${dist.name}/..&quot; username=&quot;ant&quot; group=&quot;ant&quot;&gt;
  135. &lt;include name=&quot;${dist.name}/**&quot;/&gt;
  136. &lt;exclude name=&quot;${dist.name}/bootstrap.sh&quot;/&gt;
  137. &lt;exclude name=&quot;${dist.name}/build.sh&quot;/&gt;
  138. &lt;/fileset&gt;
  139. &lt;/tar&gt; </pre>
  140. <p>This example shows building a tar which uses the GNU extensions for long paths and
  141. where some files need to be marked as executable (mode 755)
  142. and the rest are use the default mode (read-write by owner). The first
  143. fileset selects just the executable files. The second fileset must exclude
  144. the executable files and include all others. </p>
  145. <p><strong>Note: </strong> The tar task does not ensure that a file is only selected
  146. by one fileset. If the same file is selected by more than one fileset, it will be included in the
  147. tar file twice, with the same path.</p>
  148. <hr>
  149. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  150. Reserved.</p>
  151. </body>
  152. </html>