public class FixCRLF extends MatchingTask implements ChainableReader
This task can take the following arguments:
When this task executes, it will scan the srcdir based on the include and exclude properties.
This version generalises the handling of EOL characters, and allows for CR-only line endings (the standard on Mac systems prior to OS X). Tab handling has also been generalised to accommodate any tabwidth from 2 to 80, inclusive. Importantly, it will leave untouched any literal TAB characters embedded within string or character constants.
Warning: do not run on binary files. Caution: run with care on carefully formatted files. This may sound obvious, but if you don't specify asis, presume that your files are going to be modified. If "tabs" is "add" or "remove", whitespace characters may be added or removed as necessary. Similarly, for CR's - in fact "eol"="crlf" or cr="add" can result in cr characters being removed in one special case accommodated, i.e., CRCRLF is regarded as a single EOL to handle cases where other programs have converted CRLF into CRCRLF.
Modifier and Type | Class and Description |
---|---|
static class |
FixCRLF.AddAsisRemove
Enumerated attribute with the values "asis", "add" and "remove".
|
static class |
FixCRLF.CrLf
Enumerated attribute with the values "asis", "cr", "lf" and "crlf".
|
Modifier and Type | Field and Description |
---|---|
static String |
ERROR_FILE_AND_SRCDIR
error string for using srcdir and file
|
fileset
Constructor and Description |
---|
FixCRLF() |
Modifier and Type | Method and Description |
---|---|
Reader |
chain(Reader rdr)
Chain this task as a reader.
|
void |
execute()
Executes the task.
|
void |
setDestdir(File destDir)
Set the destination where the fixed files should be placed.
|
void |
setEncoding(String encoding)
Specifies the encoding Ant expects the files to be
in--defaults to the platforms default encoding.
|
void |
setEof(FixCRLF.AddAsisRemove attr)
Specify how DOS EOF (control-z) characters are to be handled.
|
void |
setEol(FixCRLF.CrLf attr)
Specify how EndOfLine characters are to be handled.
|
void |
setFile(File file)
Set a single file to convert.
|
void |
setFixlast(boolean fixlast)
Specify whether a missing EOL will be added
to the final line of a file.
|
void |
setJavafiles(boolean javafiles)
Set to true if modifying Java source files.
|
void |
setOutputEncoding(String outputEncoding)
Specifies the encoding that the files are
to be written in--same as input encoding by default.
|
void |
setPreserveLastModified(boolean preserve)
Set whether to preserve the last modified time as the original files.
|
void |
setSrcdir(File srcDir)
Set the source dir to find the source text files.
|
void |
setTab(FixCRLF.AddAsisRemove attr)
Specify how tab characters are to be handled.
|
void |
setTablength(int tlength)
Specify tab length in characters.
|
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
clone, getDescription, getLocation, getProject, setDescription, setLocation
public static final String ERROR_FILE_AND_SRCDIR
public final Reader chain(Reader rdr)
chain
in interface ChainableReader
rdr
- Reader to chain.public void execute() throws BuildException
execute
in class Task
BuildException
- on error.public void setDestdir(File destDir)
destDir
- the destination directory.public void setEncoding(String encoding)
encoding
- String encoding name.public void setEof(FixCRLF.AddAsisRemove attr)
attr
- valid values:
public void setEol(FixCRLF.CrLf attr)
attr
- valid values:
public void setFile(File file)
file
- the file to convert.public void setFixlast(boolean fixlast)
fixlast
- whether to fix the last line.public void setJavafiles(boolean javafiles)
javafiles
- whether modifying Java files.public void setOutputEncoding(String outputEncoding)
outputEncoding
- String outputEncoding name.public void setPreserveLastModified(boolean preserve)
preserve
- true if timestamps should be preserved.public void setSrcdir(File srcDir)
srcDir
- the source directory.public void setTab(FixCRLF.AddAsisRemove attr)
attr
- valid values:
public void setTablength(int tlength) throws BuildException
tlength
- specify the length of tab in spaces.BuildException
- on error.