ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bailey, Darragh" <>
Subject RE: Exclude and Include folders
Date Mon, 29 Nov 2010 10:40:30 GMT

> -----Original Message-----
> From: [] 
> Sent: 29 November 2010 07:08
> To:
> Subject: Exclude and Include folders
> I want to include and exclude folders from directory listing, 
> say I have  following folders:
> Abc/workspace
> Def/workspace
> Ghi/workspace
> Jkl/workspace
> Mno/workspace
> And so on
> I want to generate a tar file for the above folders but wants 
> to exclude all "workspace" folders, I tried like this:
> <tar destfile="archive_${KILLME}.tar" >
>             <tarfileset dir="${base.dir}">
>                 <filename name="jobs/"/>
>                 <not>
>                    <filename name="jobs/**/workspace/"/>
>                 </not>
>             </tarfileset>
>         </tar>
> But it takes forever to generate tar file because each of 
> "workspace" directory conatins huge data and these are the 
> folders I want to exclude in my tar file.
> Any idea where I am wrong or any thoughts should I do to 
> resolve this issue.

I'm not familiar with how Ant's fileset scanner is coded, but from my use of it I suspect
that the following is what is happening.

Filename entries are treated as selectors, and are applied after the fileset scanner has built
a list of directories and files. So it will scan for everything and if some of the directories
you wish to exclude have large numbers of files in them, they will be included in the initial
list and subsequently discarded.

If you make use of the exclude (possibly also the include as well, but not sure) tag, then
when the fileset is scanning for files it will use the exclude value to skip scanning anything
that matches. So if the directories that you want to exclude have a lot of child elements,
using exclude will reduce the number of files that are scanned and added to the internal list
for comparison against the includes list.

Given that you have a large number of files under the workspace directories it's likely that
using exclude instead of a negative filename test would be faster.

So try something like the following instead. Not tested, so you may need to adjust the patterns.

<tar destfile="archive_${KILLME}.tar" >
  <tarfileset dir="${base.dir}">
    <include name="jobs/**" />
    <exclude name="**/workspace" />

Darragh Bailey

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message