Reputation: 947
I have been struggling to workout how to exclude items from the exploded war using the maven overlay plugin.
I have the following:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>build-directory-tree</id>
<phase>process-resources</phase>
<goals>
<goal>exploded</goal>
</goals>
<configuration>
<overlays>
<overlay>
<groupId>com.mycompany.Online</groupId>
<artifactId>MyCompanyOnline</artifactId>
<excludes>
<exclude>WEB-INF/web.xml,WEB-INF/applicationContext.xml,WEB-INF/wro/**,WEB-INF/wro/wro-mapping.properties</exclude>
</excludes>
</overlay>
</overlays>
</configuration>
</execution>
</executions>
</plugin>
The web.xml and applicationContext.xml get excluded fine but they are located under: ${basedir}/src/main/webapp/WEB-INF/
The remaining directory and files in that exclude list are not excluded. These are located in the exploded war under: ${project.build.directory}/${project.build.finalName}/WEB-INF/wro/
I am not sure what I could be doing differently to exclude the contents of ${project.build.directory}/${project.build.finalName}/WEB-INF/wro/
No matter what I try those files are stilled overlayed despite the exclude.
Upvotes: 3
Views: 3839
Reputation: 947
After digging around for ages and trying different configurations I finally found what works.
Using mvn clean install -X on the child that is overlaying the parent I confirmed the files were being copied as there was a "+" symbol instead of a "-". In fact the files I though were being excluded because of the exclude block where actually excluded because the child has a file with the same name in the same location.
Eventually I looked in the plugin.xml for the maven-war-plugin-2.2.jar and I found this parameter: dependentWarExcludes which according to the xml is:
<deprecated>Use <overlay><excludes>
instead</deprecated>
As can be seen in my question above I tried to use <exclude>
in <overlay>
as recommended but that was actually not working for anything. In the end dependentWarExcludes worked after restructuring the plugin block as follows:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>com.mycompany.Online</groupId>
<artifactId>MyCompanyOnline</artifactId>
</overlay>
</overlays>
<dependentWarExcludes>WEB-INF/web.xml,WEB-INF/applicationContext.xml,WEB-INF/wro/</dependentWarExcludes>
</configuration>
<executions>
<execution>
<id>build-directory-tree</id>
<phase>process-resources</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
</plugin>
Upvotes: 4