【1】path和location屬性的區(qū)別:
<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可以用于指向存在多個(gè)文件的位置,而location只能指向單個(gè)的文件或目錄。另外path可以被設(shè)定id,供其它的path或classpath引用。如:<path id="main-classpath">,而classpath則沒(méi)有
【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"/> 方式③:指向單個(gè)目錄
<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.
-------------------------------------------------------------
生活就像打牌,不是要抓一手好牌,而是要盡力打好一手爛牌。