What's the difference between a nested path and fileset?

混江龙づ霸主 提交于 2019-12-03 17:20:17

问题


I have been googling for the "Differences between fileset and path" article for some time, but have found nothing useful. For example, what is the difference between the following (say, there is a someDir directory, which contains .jar files and has no subdirectories):

<path id="somePathId">
    <pathelement path="someDir"/>
</path>

<path id="someId">
  <path refid="somePathId" />
</path>

and

<path id="someId">
  <fileset dir="someDir">
     <include name="*.*">
  </fileset>
</path>

?


回答1:


They are used in different situations.

fileset is used to specify a group of files. You can use selectors and patternsets to get only the files you want.

classpath is used to specify classpath references. classpath can be specified with a single jar (location="..."), a ; or : separated list of jars (path="...") or with nested resource collections (like fileset).

Also if you want to debug them, it is different:

<echo message="Build-path: ${toString:build-path}" />

vs

<property name="debug.classpath" refid="classpath"/>
<echo message="Classpath = ${debug.classpath}"/>

As for your scripts,

<path id="somePathId">
    <pathelement location="someDir"/>
</path>

I did not test it but according to the documentation path= expects a ; or : separated list of jars. This is not the same as your second example.




回答2:


The major difference between a <path> and a <fileset> is that in <fileset> you can specify if you want to include or exclude certain type of files (Basically, its a group of files within a path... not necessary all the files), for eg:

<path id="someId">
  <fileset dir="someDir">
     <include name="*.java">
     <include name="*.properties">
  </fileset>
</path>


来源:https://stackoverflow.com/questions/6544571/whats-the-difference-between-a-nested-path-and-fileset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!