Description

Adjusts a text file to local conventions.

The set of files to be adjusted can be refined with the includesincludesfileexcludesexcludesfile and defaultexcludes attributes. Patterns provided through the includes or includesfile attributes specify files to be included. Patterns provided through the exclude or excludesfile attribute specify files to be excluded. Additionally, default exclusions can be specified with the defaultexcludes attribute. See the section on directory-based tasks, for details of file inclusion/exclusion patterns and their usage.

This task forms an implicit FileSet and supports most attributes of <fileset> (dir becomes srcdir) as well as the nested <include><exclude> and <patternset> elements.

The output file is only written if it is a new file, or if it differs from the existing file. This prevents spurious rebuilds based on unchanged files which have been regenerated by this task.

Since Apache Ant 1.7, this task can be used in a filterchain.

Parameters

Attribute Description Required
As Task As Filter
srcDir Where to find the files to be fixed up. One of these  
file Name of a single file to fix. Since Ant 1.7  
destDir Where to place the corrected files. Defaults to srcDir (replacing the original file). No  
includes comma- or space-separated list of patterns of files that must be included. All files are included when omitted. No  
includesfile the name of a file. Each line of this file is taken to be an include pattern. No  
excludes comma- or space-separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No  
excludesfile the name of a file. Each line of this file is taken to be an exclude pattern. No  
defaultexcludes indicates whether default excludes should be used or not ("yes"/"no"). Default excludes are used when omitted. No  
encoding The encoding of the files. No; defaults to default JVM encoding.  
outputencoding The encoding to use when writing the files. Since Ant 1.7 No; defaults to the value of the encoding attribute.  
preservelastmodified Whether to preserve the last modified date of source files. Since Ant 1.6.3 No; default is false  
eol Specifies how end-of-line (EOL) characters are to be handled. The EOL characters are CR, LF and the pair CRLF. Valid values for this property are:

  • asis: leave EOL characters alone
  • cr: convert all EOLs to a single CR
  • lf: convert all EOLs to a single LF
  • crlf: convert all EOLs to the pair CRLF
  • mac: convert all EOLs to a single CR
  • unix: convert all EOLs to a single LF
  • dos: convert all EOLs to the pair CRLF

Default is based on the platform on which you are running this task. For Unix platforms (including Mac OS X), the default is "lf". For DOS-based systems (including Windows), the default is "crlf". For Mac environments other than OS X, the default is "cr".

This is the preferred method for specifying EOL. The "cr" attribute (see below) is now deprecated.

N.B.: One special case is recognized. The three characters CR-CR-LF are regarded as a single EOL. Unless this property is specified as "asis", this sequence will be converted into the specified EOL type.

No
cr Deprecated. Specifies how CR characters are to be handled at end-of-line (EOL). Valid values for this property are:

  • asis: leave EOL characters alone.
  • add: add a CR before any single LF characters. The intent is to convert all EOLs to the pair CRLF.
  • remove: remove all CRs from the file. The intent is to convert all EOLs to a single LF.

Default is based on the platform on which you are running this task. For Unix platforms, the default is "remove". For DOS based systems (including Windows), the default is "add".

N.B.: One special case is recognized. The three characters CR-CR-LF are regarded as a single EOL. Unless this property is specified as "asis", this sequence will be converted into the specified EOL type.

No
javafiles Used only in association with the "tab" attribute (see below), this boolean attribute indicates whether the fileset is a set of java source files ("yes"/"no"). Defaults to "no". See notes in section on "tab". No
tab Specifies how tab characters are to be handled. Valid values for this property are:

  • add: convert sequences of spaces which span a tab stop to tabs
  • asis: leave tab and space characters alone
  • remove: convert tabs to spaces

Default for this parameter is "asis".

N.B.: When the attribute "javafiles" (see above) is "true", literal TAB characters occurring within Java string or character constants are never modified. This functionality also requires the recognition of Java-style comments.

N.B.: There is an incompatibility between this and the previous version in the handling of white space at the end of lines. This version does not remove trailing whitespace on lines.

No
tablength TAB character interval. Valid values are between 2 and 80 inclusive. The default for this parameter is 8. No
eof Specifies how DOS end of file (control-Z) characters are to be handled. Valid values for this property are:

  • add: ensure that there is an EOF character at the end of the file
  • asis: leave EOF characters alone
  • remove: remove any EOF character found at the end

Default is based on the platform on which you are running this task. For Unix platforms, the default is remove. For DOS based systems (including Windows), the default is asis.

No
fixlast Whether to add a missing EOL to the last line of a processed file.
Ignored if EOL is asis.
Since Ant 1.6.1
No; default is true

Examples

<fixcrlf srcdir="${src}" includes="**/*.sh"
eol="lf" eof="remove" />

Replaces EOLs with LF characters and removes eof characters from the shell scripts. Tabs and spaces are left as is.

<fixcrlf srcdir="${src}"
includes="**/*.bat" eol="crlf" />

Replaces all EOLs with cr-lf pairs in the batch files. Tabs and spaces are left as is. EOF characters are left alone if run on DOS systems, and are removed if run on Unix systems.

<fixcrlf srcdir="${src}"
includes="**/Makefile" tab="add" />

Sets EOLs according to local OS conventions, and converts sequences of spaces and tabs to the minimal set of spaces and tabs which will maintain spacing within the line. Tabs are set at 8 character intervals. EOF characters are left alone if run on DOS systems, and are removed if run on Unix systems. Many versions of make require tabs prior to commands.

<fixcrlf srcdir="${src}" includes="**/*.java"
tab="remove" tablength="3"
eol="lf" javafiles="yes" />

Converts all EOLs in the included java source files to a single LF. Replace all TAB characters except those in string or character constants with spaces, assuming a tab width of 3. If run on a unix system, any CTRL-Z EOF characters at the end of the file are removed. On DOS/Windows, any such EOF characters will be left untouched.

<fixcrlf srcdir="${src}"
includes="**/README*" tab="remove" />

Sets EOLs according to local OS conventions, and converts all tabs to spaces, assuming a tab width of 8. EOF characters are left alone if run on DOS systems, and are removed if run on Unix systems. You never know what editor a user will use to browse READMEs.

refer : https://ant.apache.org/manual/Tasks/fixcrlf.html / http://sepp.oetiker.ch/ant-1.6.5-rp/manual/api/org/apache/tools/ant/taskdefs/FixCRLF.html

JAVA_build_ant_FixCRLF的更多相关文章

随机推荐

  1. Android中的SQLiteOpenHelper类

    SQLiteOpenHelper是Android提供的一个管理数据库的工具类,可用于管理数据库的创建和版本更新.一般的用法是创建SQLiteOpenHelper的子类,并扩张它的onCreate(SQ ...

  2. ALTIUM DESIGNER怎么定义差分对布线

    方法一:第一步是在原理图中声明,这样做的目的是为了让差分对布线器清楚哪两个网络是属于同一组差分对,设计编译器将查找格式为NETNAME_N和NETNAME_P(即以_N和_P为后缀)的两个同名网络.这 ...

  3. 自解压的方式创建VC++程序的打包

    Walkthrough: Deploying a Visual C++ Application By Using the Visual C++ Redistributable Package Visu ...

  4. Git Bash下实现复制粘贴等快速编辑功能

    在windows下使用Git Bash会经常用到选中.复制.粘贴等功能,但是一般用的方法会很复杂,笔者经过查阅一些资料,特整理一些常见编辑功能的实现方法. (1)默认方法: 单击左上角的logo ic ...

  5. cf435A Queue on Bus Stop

      A. Queue on Bus Stop time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. AES的S-BOX构造

    利用GF(2^8)乘法逆元,以及矩阵运算,可以构造出AES的SBOX. 求乘法逆元的一般方法是利用扩展欧几里得定理,在这里我取了个巧. 因为我已经有了GF的指数表(见上一篇文),利用指数表可以轻易地构 ...

  7. aptana 插件离线下载方式

    aptana 插件离线下载方式 Aptana 网站改版后取消了eclipse 插件的zip直接下载地址,其实aptana 官网仍还提供aptana 插件的zip包下载不过比较隐蔽而已.很多人在线安装时 ...

  8. Linux安装WebLogic12

    # groupadd weblogic# useradd -g weblogic weblogic# passwd weblogic# mkdir -p /var/bea# chown -R webl ...

  9. 字符串数组越界bug(2)

    概述 数组下标从0開始,尽管从初学都已经知道,<陷阱与缺陷>重复强调,而在指尖运动中,就有那么几次不小心,让"精子"掉进这个"洞里"!其次,C语言字 ...

  10. Qt Creator实现状态栏显示

    在程序主窗口Mainwindow中,有菜单栏,工具栏,中心部件和状态栏.前面几个已经讲过了,这次讲解状态栏的使用. 程序中有哪些不明白的类或函数,请自己查看帮助. 1.我们在mainwindow.h中 ...