Filtering in Maven War Plugin
I don't understand the following filter configuration for maven war plugin. Can someone explain to me what they are doing? I marked the code with first example and second example
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<!--First Example-->
<resource>
<directory>/src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.xhtml</include>
</includes>
</resource>
<!--Second Example-->
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.xhtml</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
source to share
Filtering in war plugin config is used to include / exclude selected directories / files. This configuration looks like this:
<resource>
<directory>/src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.xhtml</include>
</includes>
</resource>
The filtering configured above is set for / src / main / webapp as the root directory There is a flag called filtering that is used to enable / disable filtering
<include>**/*.xml</include>
means all .xml files in any subdirectory of the root directory (/ src / main / webapp) will be included. Next include means the same thing, but with .xhtml files
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.xhtml</exclude>
</excludes>
</resource>
All options are the same as in the previous part, except for the exception, which have the opposite meaning to include $ {basedir} is used when the root i is in a different path, then pom.xml. In the above example, this is optional
Hope this helps to figure it out.
source to share
I know this is kind of an old question, but the other answer is so misleading that I felt I should clear it up ...
Filtering in Maven usually refers to the concept of replacing overridden properties in processed text files (like replacing occurrences ${project.version}
in your actual version of a project).
Your configuration can be read like this: every XML and / or XHTML file should undergo property substitution when copied to the target directory, while everything else should be simply copied to the target directory without any processing.
Further reading:
source to share