1
votes

Recently I configured my application to use "skinny wars" that was described on codehaus (title: Solving the skinny war problem). Basically I exclude all jars from the war and add it as a war and pom dependency to the ear. Now I ran into a problem with two jars. So to me the logical thing to do was include them in the war file using packagingInclude.

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
        <packagingIncludes>WEB-INF/lib/A.jar, WEB-INF/lib/B.jar</packagingIncludes>
    </configuration>
</plugin>

Using a regex as showed in de plugin documentation and this answer but it didn't seem to do anything. It just excludes everyting.

In the source code of the plugin I found that it uses the DocumentScanner of org.codehaus.plexus ยป plexus-utils. I didn't quite understand how it works.

I thought this was a no brainer. But what am I doing wrong? Could it be that the inclusion doesn't work when A is also a transitive dependency of C?

Edit: Does plugin version play any role? Now I am using 2.6 but previously version 2.1-alpha-2 was used.

2

2 Answers

1
votes

Found this answer as well. The following line (and only this line) works:

<packagingExcludes>%regex[WEB-INF/lib/(?!common-A|common-B).*.jar]</packagingExcludes>

Only common-A-x.x.jar and common-B-x.x.jar are in the WEB-INF/libfolder of the war file. It should be possible to extract the common part in the regex but what I tried didn't work.

0
votes

try to use the includes only without the wildcard excludes definition. Since you exclude all jars this eats up your includes. As far as I understand the doc (and from my memories), the default is to include everything but as soon as you specify an include the plugin will only include your list of jars.