ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Smith <mich...@sneakerlabs.com>
Subject Re: Why "**" in includes???
Date Wed, 23 Feb 2000 19:45:43 GMT
Kevin A. Burton" wrote:
> I don't know if I missed this.  But why is it necessary to have:
> 
> <jar .....  includes="org/**"/>
> 
> why not just:
> 
> <jar .....  includes="org/*"/>
> 
> or even
> 
> <jar .....  includes="org"/>
> 
> Note that the last two do not work.
> 
> Anyone have any idea?  It usually looks really bad when I am <jar>ing
> multiple dirs to do a dist.

According to the documentation, if you really don't like the **, you
could use includes="org/" to get what you are looking for.  This is 
documented in the "Directory based tasks" section of the documentation. 
Here's a link [watch URL line wrapping]:
http://jakarta.apache.org/cvsweb/index.cgi/~checkout~/jakarta-ant/docs/index.html?rev=1.10&content-type=text/html#directorybasedtasks

And the relevant snippet:

----8<-----------------------------------------------------------------

Matching is done per-directory. This means that first the first
directory in the pattern is matched against the first directory in
the path to match. Then the second directories are matched, and so
on. E.g. when we have the pattern '/?abc/*/*.java' and the path
'/xabc/foobar/test.java', then first '?abc' is matched with 'xabc',
then '*' is matched with 'foobar' and finally '*.java' is matched
with 'test.java'. They all match so the path matches the pattern.

Too make things a bit more flexible, we add one extra feature, which
makes it possible to match multiple directory levels. This can be
used to match a complete directory tree, or a file anywhere in the
directory tree. To do this, '**' must be used as the name of a
directory. When '**' is used as the name of a directory in the 
pattern, it matches zero or more directories. For instance: 
'/test/**' matches all files/directories under '/test/', such as
'/test/x.java', or '/test/foo/bar/xyz.html', but not '/xyz.xml'.

There is one "shorthand", if a pattern ends with '/' or '\', then
'**' is appended. E.g. "mypackage/test/" is interpreted as were it
"mypackage/test/**".

Examples:

**/CVS/*      Matches all files in CVS directories, that can be
              located anywhere in the directory tree.
 
              Matches:
 
              CVS/Repository
              org/apache/CVS/Entries

              But not:
 
              org/apache/CVS/foo/bar/Entries ('foo/bar/' part does
              not match

[a couple more examples snippet here]

**/test/**    Matches all files which have a directory 'test' in their
              path, including 'test' as a filename.

When these patterns are used in inclusion and exclusion, you have a
powerful way to select just the files you want.

Examples

  <copydir srcdir="${src}"
           destdir="${dist}"
           includes="**/images/*"
           excludes="**/*.gif" />

This copies all files in directories called "images", that are located
in the directory tree "${src}" to the destination "${dist}", but
excludes all "*.gif" files from the copy.

----8<-----------------------------------------------------------------

Regards,
Michael
-- 
michael@sneakerlabs.com
http://www.sneakerlabs.com

Mime
View raw message