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