ant随笔–path and fileset
<fileset id="sourec.fileset" dir="src" includes="**/*.java"/> <!--在fileset中设置id属性。在其他datatype中可能需要refid属性,这个refid就是fileset中的id,比如--> <copy todir="backup"> <fileset refid="source.fileset"/> </copy>
其他常用的还有property,path,mkdir,target,javac,classpath
例如:
<property name="build.classes.dir" location="build/classes"/> <path id="compile.classpath"> <pathelement location="lib/junit.jar"/> </path> <mkdir dir="${build.classes.dir}"/> <target name="compile"> <javac destdir="${build.classes.dir}" debug="true" srcdir="src"> <classpath refid="compile.classpath"/> </javac> </target>
path:包含一系列有序元素,这些元素可以使文件地址,也可以是路径。既可以使用classpath标签,也可以使用path标签
比如:
<path> <pathelement location="lib/junit.jar"/> </path> <path> <pathelement path="build/classes;lib/junit.jar"/> </path> <path location="lib/junit.jar"/><!--这是单个文件--> <path path="build/classes:lib/junit.jar"/><!--这是多文件-->
当然path也可以使用我们刚刚看到的fileset标签:
<path> <fileset dir='lib"> <include name="*.jar"/> </fileset> </path>
path 也有id属性,所以你当然也可以这样使用:
<path location="lib/junit.jar" id="junit.path"/> <path refid="jubit.path"/>
在ant中,像classpath、sourcepath、bootclasspath、extdirs这些都是path。所以都可以使用refid去引用path。
test
testds