2013-05-07 94 views
1

這裏是我的目錄結構:螞蟻非遞歸文件集

module/ 
    a/ 
     foo.php 
     b/ 
      bar.php 
    b/ 
    c/ 

我想爲下模塊每個目錄運行命令/但非遞歸,所以只有這些應包括:

a/ 
b/ 
c/ 

如果我這樣做:

<target name="foo"> 
    <apply executable="ls"> 
     <arg value="-l" /> 
     <fileset dir="${basedir}/module/"> 
     </fileset> 
    </apply> 
</target> 

這將遞歸運行的每個目錄下模塊文件。

回答

5

你只想在第一級目錄中做到這一點?

<target name="foo"> 
    <apply executable="ls"> 
     <arg value="-l" /> 
     <dirset dir="${basedir}/module/"> 
      <include name="*"/> 
     </dirset> 
    </apply> 
</target> 

請注意<include>。我僅指定在我的<dirset/>中指定的目錄下的目錄。如果我說,<include names="**/*"/>,它會指定所有目錄。

當您處理目錄而不是文件時,請使用<dirset/>而不是<fileset/><fileset/>用於指定文件。 <dirset/>用於指定目錄。