Dinuk
Dinuk

Reputation: 1526

Maven - File Inclusion/Exclusion regexp syntax rules

I would like to know more about the "regular Expression" [1] syntax that is used in Maven plus other build tools like Ant, Grunt and so on.

Consider the snippet below - specifically the two <include> directives to specify the

to be included/excluded

 <project>
      ...
      <name>My Resources Plugin Practice Project</name>
      ...
      <build>
        ...
        <resources>
          <resource>
            <directory>src/my-resources</directory>
            <includes>
              <include>**/*.txt</include>
              <include>**/*.rtf</include>
            </includes>
          </resource>
          ...
        </resources>
        ...
      </build>
      ...
    </project>

Is there any documentation available on an exhaustive list of rules? I could not find anything (other than the examples provided) on this specific syntax. Rather I am forced to rely upon trial and error (rather than concrete understanding and reasoning).

Footnote: 1. I say "Regular Expression" - in a broad sense here. These syntax rules do not seem to be compatible with Perl5/6 Regular Expression syntax. So, I am assuming it is a different regex dialect?

Upvotes: 3

Views: 5739

Answers (1)

beerbajay
beerbajay

Reputation: 20270

These are Ant patterns.

*.java matches .java, x.java and FooBar.java, but not FooBar.xml (does not end with .java).

?.java matches x.java, A.java, but not .java or xyz.java (both don't have one character before .java).

...

When ** is used as the name of a directory in the pattern, it matches zero or more directories.

Upvotes: 5

Related Questions