------ Including and Excluding Files From the WAR ------ Dennis Lundberg ------ 2011-11-21 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Including and Excluding Files From the WAR It is possible to include or exclude certain files from the WAR file, by using the <<<\>>> and <<<\>>> configuration parameters. They each take a comma-separated list of Ant file set patterns. You can use wildcards such as <<<**>>> to indicate multiple directories and <<<*>>> to indicate an optional part of a file or directory name. Here is an example where we exclude all JAR files from <<>>: +-----------------+ ... maven-war-plugin ${project.version} WEB-INF/lib/*.jar ... +-----------------+ Sometimes even such wildcards are not enough. In these cases you can use regular expressions with the <<<%regex[]>>> syntax. Here is a real life use case in which this is used. In this example we want to exclude any commons-logging and log4j JARs, but we do not want to exclude the log4j-over-slf4j JAR. So we want to exclude <<.jar>>> but keep the <<.jar>>>. +-----------------+ ... maven-war-plugin ${project.version} WEB-INF/lib/commons-logging-*.jar, %regex[WEB-INF/lib/log4j-(?!over-slf4j).*.jar] ... +-----------------+ If you have more real life examples of using regular expressions, we'd like to know about them. Please file an issue in {{{../issue-tracking.html}our issue tracker}} with your configuration, so we can expand this page.