'What is the difference between `warSourceExcludes` and `packagingExcludes` in Maven
The Maven WAR plugin has two configuration options: warSourceExcludes and packagingExcludes. There is some documentation on packagingExcludes, saying that:
It is possible to include or exclude certain files from the WAR file, by using the
<packagingIncludes>and<packagingExcludes>configuration parameters.
However, I find it very difficult to find information on warSourceExcludes.
What is the difference between these two configuration options?
I'm using Maven 3.1.1 and the WAR plugin is version 2.4
Solution 1:[1]
warSourceExcludes: The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.
packagingExcludes: The comma separated list of tokens to exclude from the WAR before packaging.
With packagingExcludes, the tokens are completely excluded from the final war file.
With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file.
As a result, if the tokens are present in the webappDirectory for example, they will not be ignored when using warSourceExcludes but will be when usingpackagingExcludes.
Solution 2:[2]
The process of producing the final war file can be simplified as two major steps:
the web resources are copied from
${warSourceDirectory}into${<webappDirectory>}, let's say it'starget/artifact/, which can be treated like:cp -r src/main/webapp/* target/artifact/<warSourceExcludes>is used at this step, so that the excluded files are NOT copied intotarget/artifact/.the output directory
target/artifactof the above step, namely${webappDirectory}, is then used as the input to produce the final war file, like:jar --create --file target/artifact.war -C target/artifact/ WEB-INF ...And here
<packagingExcludes>is used, deciding what to pack up fromtarget/artifact/.
see https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Naman |
| Solution 2 |
