转自:http://www.blogjava.net/pengpenglin/archive/2008/04/21/194509.html
【1】path和location属性的区别:
<classpath>
<pathelement path="${classpath}"/>
<pathelement location="lib/helper.jar"/>
</classpath>
原文:The location attribute specifies a single file or directory relative to the project's base directory (or an absolute filename), while the path attribute accepts colon- or semicolon-separated lists of locations. The path attribute is intended to be used with predefined paths - in any other case, multiple
elements with location attributes should be preferred.
从中我们可以看出path可以用于指向存在多个文件的位置,而location只能指向单个的文件或目录。另外path可以被设定id,供其它的path或classpath引用。如:<path id="main-classpath">,而classpath则没有
【2】综合示例:
In addition, DirSets, FileSets, and FileLists can be specified via nested <dirset>, <fileset>, and <filelist> elements, respectively. Note: The order in which the files building up a FileSet are added to the path-like structure is not defined.
<classpath>
<pathelement path="${classpath}"/> 方式① :引用特定的变量
<fileset dir="lib"> 方式② :指向特定的文件集
<include name="**/*.jar"/>
</fileset>
<pathelement location="classes"/> 方式③:指向单个目录
<dirset dir="${build.dir}"> 方式④:指向特定目录集
<include name="apps/**/classes"/>
<exclude name="apps/**/*Test*"/>
</dirset>
<filelist refid="third-party_jars"/> 方式⑤:引用指定文件列表
</classpath>
This builds a path that holds the value of ${classpath}, followed by all jar files in the lib directory, the classes directory, all directories named classes under the apps subdirectory of ${build.dir}, except those that have the text Test in their name, and the files specified in the referenced FileList.