[14627] | 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
|
---|
| 33 | supports all attributes of <code><fileset></code>
|
---|
| 34 | (<code>dir</code> becomes <code>srcdir</code>) as well as the nested
|
---|
| 35 | <code><include></code>, <code><exclude></code> and
|
---|
| 36 | <code><patternset></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 | ("yes"/"no"). 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 "lf".
|
---|
| 110 | For DOS based systems (including Windows), the default is
|
---|
| 111 | "crlf". For Mac OS, the default is "cr".
|
---|
| 112 | <p>
|
---|
| 113 | This is the preferred method for specifying EOL. The
|
---|
| 114 | "<i><b>cr</b></i>" 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 "asis",
|
---|
| 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 "remove".
|
---|
| 146 | For DOS based systems (including Windows), the default is
|
---|
| 147 | "add".
|
---|
| 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 "asis",
|
---|
| 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 | "<i><b>tab</b></i>" attribute (see below), this
|
---|
| 163 | boolean attribute indicates whether the fileset is a set
|
---|
| 164 | of java source files
|
---|
| 165 | ("yes"/"no"). Defaults to
|
---|
| 166 | "no". See notes in section on "tab".
|
---|
| 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 "asis".
|
---|
| 180 | <p>
|
---|
| 181 | <i>N.B.</i>: When the attribute
|
---|
| 182 | "<i><b>javafiles</b></i>" (see above) is
|
---|
| 183 | "true", 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> <fixcrlf srcdir="${src}"
|
---|
| 232 | eol="lf"
|
---|
| 233 | eof="remove"
|
---|
| 234 | includes="**/*.sh"
|
---|
| 235 | /></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> <fixcrlf srcdir="${src}"
|
---|
| 239 | eol="crlf"
|
---|
| 240 | includes="**/*.bat"
|
---|
| 241 | /></pre>
|
---|
| 242 | <p>Replaces all EOLs with cr-lf pairs in the batch files.
|
---|
| 243 | Tabs and spaces are left as is.
|
---|
| 244 | EOF characters are left alone if run on
|
---|
| 245 | DOS systems, and are removed if run on Unix systems.</p>
|
---|
| 246 | <pre> <fixcrlf srcdir="${src}"
|
---|
| 247 | tab="add"
|
---|
| 248 | includes="**/Makefile"
|
---|
| 249 | /></pre>
|
---|
| 250 | <p>Sets EOLs according to local OS conventions, and
|
---|
| 251 | converts 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
|
---|
| 254 | run on DOS systems, and are removed if run on Unix systems.
|
---|
| 255 | Many versions of make require tabs prior to commands.</p>
|
---|
| 256 | <pre> <fixcrlf srcdir="${src}"
|
---|
| 257 | tab="remove"
|
---|
| 258 | tablength="3"
|
---|
| 259 | eol="lf"
|
---|
| 260 | javafiles="yes"
|
---|
| 261 | includes="**/*.java"
|
---|
| 262 | /></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> <fixcrlf srcdir="${src}"
|
---|
| 272 | tab="remove"
|
---|
| 273 | includes="**/README*"
|
---|
| 274 | /></pre>
|
---|
| 275 | <p>Sets EOLs according to local OS conventions, and
|
---|
| 276 | converts all tabs to spaces, assuming a tab width of 8.
|
---|
| 277 | EOF characters are left alone if run on
|
---|
| 278 | DOS systems, and are removed if run on Unix systems.
|
---|
| 279 | You never know what editor a user will use to browse README's.</p>
|
---|
| 280 | <hr>
|
---|
| 281 | <p align="center">Copyright © 2000-2004 The Apache Software Foundation. All rights
|
---|
| 282 | Reserved.</p>
|
---|
| 283 |
|
---|
| 284 | </body>
|
---|
| 285 | </html>
|
---|