ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: Fileset with "empty" patternset selects all files instead
Date Mon, 05 Oct 2009 14:26:06 GMT
A patternset is a series of includes and excludes that can be used over and
over again in  various filesets.  When you specify an empty patternset,
you're not specifying any exclude or includes. Thus, your fileset acts in
the default manner of:

<fileset dir="${mydir}>

I see what you want to. One possibility is to create the default patternset
that includes a bogus file:

<patternset id="mypatternset">
   <include name=""/>

<fileset dir="${mydir}">
   <patternset refid="mypatternset"

This will be an empty fileset, but if you add more includes in your
patternset, the other files will be included. I do this when I use a
macrodef that allow users to pass a set of files as a parameter. This way,
if they pass an empty parameter, I don't include any files.

On the other hand, I believe includes override excludes in a fileset. That
is, if you exclude everything, but then include specific files, your fileset
will include all your included files, but if you don't specify any includes,
your fileset will still be empty.

On Sun, Oct 4, 2009 at 6:26 AM, efe4itcc <> wrote:

> Hi
> Env: JDK 1.6.0, ANT 1.7.1
> I spend some time figuring out a classpath dependancy problem in my build
> file, and finally cornered the cause to the surprinsing file selection of
> <fileset> when using the following syntax.
> <patternset id="mypatternset">
> </patternset>
> <path id="path.main.compile">
>  <fileset dir="${mydir}">
>    <patternset refid="mypatternset"/>
>  </fileset>
> </path>
> The above syntax make "path.main.compile" contains all files under
> ${mydir}.
> Is patternset applying an implicit <include name="**"/> ?
> Is fileset discarding the patternset as it does not declare any pattern ?
> Is that the intended behavior?
> To fix the problem, I just have to be more specific in the patternset
> definition, such as:
> <patternset id="mypatternset">
>   <exclude name="**"/>
> </patternset>
> This example might seem of no use :)
> However I use this path reference to designate a project's dependencies to
> other of our projects, and some projects are standalone, so I need an empty
> patternset for them.
> Regards
> --
> View this message in context:
> Sent from the Ant - Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

David Weintraub

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message