TJ Grant
TJ Grant

Reputation: 59

Maven 3.2.2 packagingExcludes

I want to exclude multiple regex expressions using the packagingExcludes element of my pom.xml. According to the Maven documentation, this element contains "a comma-separated list of Ant file set patterns".

However, from what I can tell each of these is evaluated as an "OR" to the others. That is if I want to do this:

<packagingExcludes>
    %regex[WEB-INF/lib(?!abc).jar],
    %regex[WEB-INF/lib(?!xyz).jar]
</packagingExcludes>

nothing gets included. abc.jar is excluded because it is not xyz.jar and xyz.jar gets excluded because it is not abc.jar.

Is there a way to get Maven to evaluate these using an "AND" relationship?

Thanks.

Upvotes: 1

Views: 482

Answers (1)

Joe
Joe

Reputation: 31087

If I understand correctly, you wish to exclude all files from WEB-INF/lib/*.jar except for abc.jar and xyz.jar.

You can solve this by providing a single regular expression that matches those exclusions. Everything in WEB-INF/lib/, except for those things that then contain (abc|xyz).jar and then end, and which goes on to end in .jar.

%regex[WEB-INF/lib/(?!(abc|xyz).jar$).*.jar]

For maintainability, you may wish to consider listing the exclusions instead.

Upvotes: 1

Related Questions