antfileset

Why `**/*ant*` exclude pattern doesn't work, but `"**/*ant*/**` works fine?


Let's say I have this in one of my targets:

<path id="files">
   <fileset dir="${env.DIRECTORY}" casesensitive="false">
     <include name="**/*.html"/>
     <exclude name="**/*ant*"/>
    </fileset>
</path>

I'd like to group all the html files, except the ones containing the string ant. The way I wrote it above, it does not work. I also tried specifying the exclude like this:

<exclude name="*ant*"/>

Please notice that the fileset has it's case sensitiveness turned off. However, if I write:

<exclude name="**/*ant*/**"/>

This does work. Why don't the first and second versions of exclude work?


Solution

  • First and second case don't match because you are searching for directory name containing ant

    Third case matches all files that have a ant element in their path, including ant as a filename.

    You can also refer this Ant documentation