Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant Pattern Matching - * vs. **

We are using TeamCity to produce *.nupkg artifacts which we don't want to be cleaned up. TeamCity provides a field where you can specify an ANT-style pattern for indicating which files you do or don't want to be cleaned up. Let's assume for a second that we have the following files which we do not want to be cleaned up:

/a.nupkg
/dir1/b.nupkg
/dir1/dir2/c.nupkg

Does the *.nupkg pattern match .nupkg files both in the root directory AND all child directories or do need to use **.*nupkg to traverse all directories?

I read the following documentation but this is still ambiguous to me: http://ant.apache.org/manual/dirtasks.html#patterns

If there is an Ant-Pattern tester (similar to http://regexpal.com/) that would be amazing.

like image 310
jakejgordon Avatar asked Oct 29 '15 14:10

jakejgordon


People also ask

What is Antpatterns?

ISBN 0-521-64568-9 . ... common approaches to solving recurring problems that prove to be ineffective. These approaches are called antipatterns.

What is Ant_ path_ matcher?

public class AntPathMatcher extends Object implements PathMatcher. PathMatcher implementation for Ant-style path patterns. Part of this mapping code has been kindly borrowed from Apache Ant. The mapping matches URLs using the following rules: ?

What is FileSet in Ant?

A FileSet is a group of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of PatternSets and Selectors. PatternSets can be specified as nested <patternset> elements.

What is Ant pattern in Java?

Apache Ant gives you two ways to create a subset of files in a fileset, both of which can be used at the same time: Only include files and directories that match any include patterns and do not match any exclude patterns in a given PatternSet.


1 Answers

To match all files, in all directories (from the base directory and deeper)

**/*.nupkg

Will match

sample.nupkg
sample-2.nupkg
tmp/sample.nupkg
tmp/other.nupkg
other/new/sample.nupkg

** will match any directory (multiple directories deep).

*.nupkg will match any file with the nupkg extension. Or just * will match any file or any directory (but just a single directory deep).

PS: There is no Ant Pattern Tester.

like image 55
Verhagen Avatar answered Oct 06 '22 04:10

Verhagen