source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual1.6.2/manual/CoreTasks/fixcrlf.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

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