antfileset

How to list all zip files in a specified directory?


I am trying to retrieve the list of all zip files present in a directory.

I have a directory ${src} which contains some zip files and I am using the following code

<target name="test">  
<dirset id="dist.contents" dir="${src}" includes="*.zip"/>  
<property name="prop.dist.contents" refid="dist.contents"/>  
<echo message="${prop.dist.contents}" />  
</target>  

but it only echoes null.

I also tried includes="*" but it didn't make any difference.

I am using Ant version 1.7.0.


Solution

  • As written in the documentation:

    A DirSet is a group of directories.

    So since you want zip files, you should use a FileSet.