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.

fixcrlf.html 12 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>FixCRLF Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="fixcrlf">FixCRLF</a></h2>
  8. <h3>Description</h3>
  9. <p>
  10. Adjusts a text file to local conventions.
  11. </p>
  12. <p>
  13. The set of files to be adjusted can be refined with the
  14. <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
  15. <i>excludesfile</i> and <i>defaultexcludes</i>
  16. attributes. Patterns provided through the <i>includes</i> or
  17. <i>includesfile</i> attributes specify files to be
  18. included. Patterns provided through the <i>exclude</i> or
  19. <i>excludesfile</i> attribute specify files to be
  20. excluded. Additionally, default exclusions can be specified with
  21. the <i>defaultexcludes</i> attribute. See the section on <a
  22. href="../dirtasks.html#directorybasedtasks">directory-based
  23. tasks</a>, for details of file inclusion/exclusion patterns
  24. and their usage.
  25. </p>
  26. <p>
  27. This task forms an implicit
  28. <a href="../CoreTypes/fileset.html">FileSet</a> and
  29. supports all attributes of <code>&lt;fileset&gt;</code>
  30. (<code>dir</code> becomes <code>srcdir</code>) as well as the nested
  31. <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code> and
  32. <code>&lt;patternset&gt;</code> elements.
  33. </p>
  34. <p>
  35. The output file is only written if it is a new file, or if it
  36. differs from the existing file. This prevents spurious
  37. rebuilds based on unchanged files which have been regenerated
  38. by this task.
  39. </p>
  40. <p>
  41. Since <b>Ant 1.7</b>, this task can be used in a
  42. <a href="../CoreTypes/filterchain.html">filterchain</a>.
  43. </p>
  44. <h3>Parameters</h3>
  45. <table border="1" cellpadding="2" cellspacing="0">
  46. <tr>
  47. <td valign="center" rowspan="2"><b>Attribute</b></td>
  48. <td valign="center" rowspan="2"><b>Description</b></td>
  49. <td align="center" valign="top" colspan="2"><b>Required</b></td>
  50. </tr>
  51. <tr>
  52. <td valign="center"><b>As Task</b></td>
  53. <td valign="center"><b>As Filter</b></td>
  54. </tr>
  55. <tr>
  56. <td valign="top">srcDir</td>
  57. <td valign="top">Where to find the files to be fixed up.</td>
  58. <td valign="top" align="center" rowspan="2">One of these</td>
  59. <td bgcolor="#CCCCCC"><nbsp /></td>
  60. </tr>
  61. <tr>
  62. <td valign="top">file</td>
  63. <td valign="top">Name of a single file to fix. <b>Since Ant 1.7</b></td>
  64. <td bgcolor="#CCCCCC"><nbsp /></td>
  65. </tr>
  66. <tr>
  67. <td valign="top">destDir</td>
  68. <td valign="top">Where to place the corrected files. Defaults to
  69. srcDir (replacing the original file).</td>
  70. <td valign="top" align="center">No</td>
  71. <td bgcolor="#CCCCCC"><nbsp /></td>
  72. </tr>
  73. <tr>
  74. <td valign="top">includes</td>
  75. <td valign="top">comma- or space-separated list of patterns of files that must be
  76. included. All files are included when omitted.</td>
  77. <td valign="top" align="center">No</td>
  78. <td bgcolor="#CCCCCC"><nbsp /></td>
  79. </tr>
  80. <tr>
  81. <td valign="top">includesfile</td>
  82. <td valign="top">the name of a file. Each line of this file is
  83. taken to be an include pattern.</td>
  84. <td valign="top" align="center">No</td>
  85. <td bgcolor="#CCCCCC"><nbsp /></td>
  86. </tr>
  87. <tr>
  88. <td valign="top">excludes</td>
  89. <td valign="top">comma- or space-separated list of patterns of files that must be
  90. excluded. No files (except default excludes) are excluded when omitted.</td>
  91. <td valign="top" align="center">No</td>
  92. <td bgcolor="#CCCCCC"><nbsp /></td>
  93. </tr>
  94. <tr>
  95. <td valign="top">excludesfile</td>
  96. <td valign="top">the name of a file. Each line of this file is
  97. taken to be an exclude pattern.</td>
  98. <td valign="top" align="center">No</td>
  99. <td bgcolor="#CCCCCC"><nbsp /></td>
  100. </tr>
  101. <tr>
  102. <td valign="top">defaultexcludes</td>
  103. <td valign="top">indicates whether default excludes should be used or not
  104. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.
  105. </td>
  106. <td valign="top" align="center">No</td>
  107. <td bgcolor="#CCCCCC"><nbsp /></td>
  108. </tr>
  109. <tr>
  110. <td valign="top">encoding</td>
  111. <td valign="top">The encoding of the files.</td>
  112. <td align="center">No; defaults to default JVM encoding.</td>
  113. <td bgcolor="#CCCCCC"><nbsp /></td>
  114. </tr>
  115. <tr>
  116. <td valign="top">preservelastmodified</td>
  117. <td valign="top">Whether to preserve the last modified
  118. date of source files. <b>Since Ant 1.6.3</b></td>
  119. <td align="center">No; default is <i>false</i></td>
  120. <td bgcolor="#CCCCCC"><nbsp /></td>
  121. </tr>
  122. <tr>
  123. <td valign="top">eol</td>
  124. <td valign="top">
  125. Specifies how end-of-line (EOL) characters are to be
  126. handled. The EOL characters are CR, LF and the pair CRLF.
  127. Valid values for this property are:
  128. <ul>
  129. <li>asis: leave EOL characters alone</li>
  130. <li>cr: convert all EOLs to a single CR</li>
  131. <li>lf: convert all EOLs to a single LF</li>
  132. <li>crlf: convert all EOLs to the pair CRLF</li>
  133. <li>mac: convert all EOLs to a single CR</li>
  134. <li>unix: convert all EOLs to a single LF</li>
  135. <li>dos: convert all EOLs to the pair CRLF</li>
  136. </ul>
  137. Default is based on the platform on which you are running
  138. this task. For Unix platforms, the default is &quot;lf&quot;.
  139. For DOS based systems (including Windows), the default is
  140. &quot;crlf&quot;. For Mac OS, the default is &quot;cr&quot;.
  141. <p>
  142. This is the preferred method for specifying EOL. The
  143. &quot;<i><b>cr</b></i>&quot; attribute (see below) is
  144. now deprecated.
  145. </p>
  146. <p>
  147. <i>N.B.</i>: One special case is recognized. The three
  148. characters CR-CR-LF are regarded as a single EOL.
  149. Unless this property is specified as &quot;asis&quot;,
  150. this sequence will be converted into the specified EOL
  151. type.
  152. </p>
  153. </td>
  154. <td valign="top" align="center" colspan="2">No</td>
  155. </tr>
  156. <tr>
  157. <td valign="top">cr</td>
  158. <td valign="top">
  159. <i><b>Deprecated.</b></i> Specifies how CR characters are
  160. to be handled at end-of-line (EOL). Valid values for this
  161. property are:
  162. <ul>
  163. <li>asis: leave EOL characters alone.</li>
  164. <li>
  165. add: add a CR before any single LF characters. The
  166. intent is to convert all EOLs to the pair CRLF.
  167. </li>
  168. <li>
  169. remove: remove all CRs from the file. The intent is
  170. to convert all EOLs to a single LF.
  171. </li>
  172. </ul>
  173. Default is based on the platform on which you are running
  174. this task. For Unix platforms, the default is &quot;remove&quot;.
  175. For DOS based systems (including Windows), the default is
  176. &quot;add&quot;.
  177. <p>
  178. <i>N.B.</i>: One special case is recognized. The three
  179. characters CR-CR-LF are regarded as a single EOL.
  180. Unless this property is specified as &quot;asis&quot;,
  181. this sequence will be converted into the specified EOL
  182. type.
  183. </p>
  184. </td>
  185. <td valign="top" align="center" colspan="2">No</td>
  186. </tr>
  187. <tr>
  188. <td valign="top">javafiles</td>
  189. <td valign="top">
  190. Used only in association with the
  191. &quot;<i><b>tab</b></i>&quot; attribute (see below), this
  192. boolean attribute indicates whether the fileset is a set
  193. of java source files
  194. (&quot;yes&quot;/&quot;no&quot;). Defaults to
  195. &quot;no&quot;. See notes in section on &quot;tab&quot;.
  196. </td>
  197. <td valign="top" align="center" colspan="2">No</td>
  198. </tr>
  199. <tr>
  200. <td valign="top">tab</td>
  201. <td valign="top">Specifies how tab characters are to be handled. Valid
  202. values for this property are:
  203. <ul>
  204. <li>add: convert sequences of spaces which span a tab stop to tabs</li>
  205. <li>asis: leave tab and space characters alone</li>
  206. <li>remove: convert tabs to spaces</li>
  207. </ul>
  208. Default for this parameter is &quot;asis&quot;.
  209. <p>
  210. <i>N.B.</i>: When the attribute
  211. &quot;<i><b>javafiles</b></i>&quot; (see above) is
  212. &quot;true&quot;, literal TAB characters occurring
  213. within Java string or character constants are never
  214. modified. This functionality also requires the
  215. recognition of Java-style comments.
  216. </p>
  217. <p>
  218. <i>N.B.</i>: There is an incompatibility between this
  219. and the previous version in the handling of white
  220. space at the end of lines. This version does
  221. <i><b>not</b></i> remove trailing whitespace on lines.
  222. </p>
  223. </td>
  224. <td valign="top" align="center" colspan="2">No</td>
  225. </tr>
  226. <tr>
  227. <td valign="top">tablength</td>
  228. <td valign="top">TAB character interval. Valid values are between
  229. 2 and 80 inclusive. The default for this parameter is 8.</td>
  230. <td valign="top" align="center" colspan="2">No</td>
  231. </tr>
  232. <tr>
  233. <td valign="top">eof</td>
  234. <td valign="top">Specifies how DOS end of file (control-Z) characters are
  235. to be handled. Valid values for this property are:
  236. <ul>
  237. <li>add: ensure that there is an EOF character at the end of the file</li>
  238. <li>asis: leave EOF characters alone</li>
  239. <li>remove: remove any EOF character found at the end</li>
  240. </ul>
  241. Default is based on the platform on which you are running this task.
  242. For Unix platforms, the default is remove. For DOS based systems
  243. (including Windows), the default is asis.
  244. </td>
  245. <td valign="top" align="center" colspan="2">No</td>
  246. </tr>
  247. <tr>
  248. <td valign="top">fixlast</td>
  249. <td valign="top">Whether to add a missing EOL to the last line
  250. of a processed file. <b>Since Ant 1.6.1</b></td>
  251. <td align="center" colspan="2">No; default is <i>true</i></td>
  252. </tr>
  253. </table>
  254. <h3>Examples</h3>
  255. <pre>&lt;fixcrlf srcdir=&quot;${src}&quot; includes=&quot;**/*.sh&quot;
  256. eol=&quot;lf&quot; eof=&quot;remove&quot; /&gt;</pre>
  257. <p>Replaces EOLs with LF characters and removes eof characters from
  258. the shell scripts. Tabs and spaces are left as is.</p>
  259. <pre>&lt;fixcrlf srcdir=&quot;${src}&quot;
  260. includes=&quot;**/*.bat&quot; eol=&quot;crlf&quot; /&gt;</pre>
  261. <p>Replaces all EOLs with cr-lf pairs in the batch files.
  262. Tabs and spaces are left as is.
  263. EOF characters are left alone if run on
  264. DOS systems, and are removed if run on Unix systems.</p>
  265. <pre>&lt;fixcrlf srcdir=&quot;${src}&quot;
  266. includes=&quot;**/Makefile&quot; tab=&quot;add&quot; /&gt;</pre>
  267. <p>Sets EOLs according to local OS conventions, and
  268. converts sequences of spaces and tabs to the minimal set of spaces and
  269. tabs which will maintain spacing within the line. Tabs are
  270. set at 8 character intervals. EOF characters are left alone if
  271. run on DOS systems, and are removed if run on Unix systems.
  272. Many versions of make require tabs prior to commands.</p>
  273. <pre>&lt;fixcrlf srcdir=&quot;${src}&quot; includes=&quot;**/*.java&quot;
  274. tab=&quot;remove&quot; tablength=&quot;3&quot;
  275. eol=&quot;lf&quot; javafiles=&quot;yes&quot; /&gt;</pre>
  276. <p>
  277. Converts all EOLs in the included java source files to a
  278. single LF. Replace all TAB characters except those in string
  279. or character constants with spaces, assuming a tab width of 3.
  280. If run on a unix system, any CTRL-Z EOF characters at the end
  281. of the file are removed. On DOS/Windows, any such EOF
  282. characters will be left untouched.
  283. </p>
  284. <pre>&lt;fixcrlf srcdir=&quot;${src}&quot;
  285. includes=&quot;**/README*&quot; tab=&quot;remove&quot; /&gt;</pre>
  286. <p>Sets EOLs according to local OS conventions, and
  287. converts all tabs to spaces, assuming a tab width of 8.
  288. EOF characters are left alone if run on
  289. DOS systems, and are removed if run on Unix systems.
  290. You never know what editor a user will use to browse READMEs.</p>
  291. <hr>
  292. <p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation. All rights
  293. Reserved.</p>
  294. </body>
  295. </html>