ANT: how to specify file pattern with whitespace

P

pete

Today I tried to specify a <fileset> which has an exludes pattern
containing a whitespace. Somehow the whitespace was interpreted as a
separator (while the , is already specified as being the separator in
filesets):

<fileset dir="test" exclude="project dir/**"/>

does not exclude the directory "project dir" and all below, but
excludes "project" and all below "dir".

Is there a way in ant to specify whitespace in filenames?
 
A

Alan Moore

Today I tried to specify a <fileset> which has an exludes pattern
containing a whitespace. Somehow the whitespace was interpreted as a
separator (while the , is already specified as being the separator in
filesets):

<fileset dir="test" exclude="project dir/**"/>

does not exclude the directory "project dir" and all below, but
excludes "project" and all below "dir".

Is there a way in ant to specify whitespace in filenames?

Apparently not. PatternSet uses a StringTokenizer with ", " as the
separator spec to break out the patterns--which comes as a surprise to
me. I guess I always assumed that the separator had to be a comma,
and any extra whitespace was just being trimmed off (even though it
says right in the docs--now that I look for it--that the separators
can be commas or spaces).

This looks like a bug to me; directory and file names with embedded
spaces are (unfortunately) valid on Windows, but Ant can't handle
them. I wonder haw many people would be affected if it were changed
so that only commas could be used as separators? I can't remember
ever seeing a build file in which commas were not used.
 
A

Alex Hunsley

Today I tried to specify a <fileset> which has an exludes pattern
containing a whitespace. Somehow the whitespace was interpreted as a
separator (while the , is already specified as being the separator in
filesets):

<fileset dir="test" exclude="project dir/**"/>

does not exclude the directory "project dir" and all below, but
excludes "project" and all below "dir".

Is there a way in ant to specify whitespace in filenames?

The other respondee answered this well - I'd just like to add it's worth
avoiding spaces in pathnames/filenames, if you can help it, just to
avoid this sort of bug.

alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top