Ant Datatype之other

Filelist(文件列表)

    Filelist是文件或目录的有序列表,其中文件或目录不一定存在。当我们需要对一组文件排序时,Filelist会派上用场。

        fileset:定义一个文件集合列表,这些文件必须确实存在

       filelist:定义一个文件集合列表,这些文件无需确实存在

Dirset(目录集)

    Dirset只用于<javadoc>和<pathconvert>任务中,path也支持嵌套的<dirset>。Dirset用于目录,有些任务只对目录进行操作。

Filterset(过滤器集)

    在<copy>和<move>任务中支持Filterset。以下三种情况可以发挥已过滤复制的优势:

        1. 将当前日期和版本信息写入到与构建相关的文件中,比如文档。

        2. 对配置文件有选择地注释。

        3. 简单生成一些源文件或者数据文件。

Datatype的引用:

测试:

<?xml version="1.0" encoding="UTF-8"?>
<project name="property">

	<path id="pathtest">
		<fileset dir="src" />
	</path>

	<property name="pathtest.property" refid="pathtest"/>

	<echo message="pathtest=${pathtest.property}"/>

	<echo message="pathtestToString=${toString:pathtest}"/>

	<patternset id="java.file" includes="**/*.java"/>

	<patternset id="all.files">
		<include name="**/*.class"/>
		<patternset refid="java.file"/>
	</patternset>

	<echo level="verbose">
		allfiles=${toString:all.files}
	</echo>

</project>

 输出:

e:\antspace\property>ant
Buildfile: e:\antspace\property\build.xml
     [echo] pathtest=e:\antspace\property\src\xuj\ant\Main.class;e:\antspace\pro
perty\src\xuj\ant\Main.java
     [echo] pathtestToString=e:\antspace\property\src\xuj\ant\Main.class;e:\ants
pace\property\src\xuj\ant\Main.java

BUILD SUCCESSFUL
Total time: 0 seconds

e:\antspace\property>ant -verbose
Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Trying the default build file: build.xml
Buildfile: e:\antspace\property\build.xml
Detected Java version: 1.6 in: D:\dev\java\jdk16027\jre
Detected OS: Windows 7
parsing buildfile e:\antspace\property\build.xml with URI = file:/e:/antspace/pr
operty/build.xml
Project base dir set to: e:\antspace\property
parsing buildfile jar:file:/D:/dev/ant/ant1.8.4/lib/ant.jar!/org/apache/tools/an
t/antlib.xml with URI = jar:file:/D:/dev/ant/ant1.8.4/lib/ant.jar!/org/apache/to
ols/ant/antlib.xml from a zip file
     [echo] pathtest=e:\antspace\property\src\xuj\ant\Main.class;e:\antspace\pro
perty\src\xuj\ant\Main.java
     [echo] pathtestToString=e:\antspace\property\src\xuj\ant\Main.class;e:\ants
pace\property\src\xuj\ant\Main.java
     [echo]
     [echo]             allfiles=patternSet{ includes: [**/*.class, **/*.java] e
xcludes: [] }
     [echo]

BUILD SUCCESSFUL
Total time: 0 seconds

 

猜你喜欢

转载自xujava.iteye.com/blog/1770405
ANT