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 KiB

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