I wasn't able to figure out how to do simple exclude filtering of files under my src/main/webapp directory by looking at the current usage examples on the maven war plug-in page. This simple tutorial describes how to use the warSourceExcludes tag to perform this task. [ Suggestion: the official documentation page for maven:war plugin could use a how-to example along the lines of what I present below].

Sometimes you want to filter out stuff in your war file that want to use for development and testing, but don't want to have included in your production environment. An example is deployment environment specific properties files that you want to have on your classpath (during dev/test), but not in your .war (so that an  admin  can twiddle the properties without cracking open your .war).

Tutorial

Here's an example of how to this.

  <build>
    <finalName>findFiles</finalName>
    <plugins>
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>2.1-beta-1</version>
          <configuration>
              <warSourceExcludes>**/*.jsp</warSourceExcludes>
          </configuration>
      </plugin>
    </plugins>
  </build>

notice the file target/example/server.properties is no longer present. You can check the .war as well, it won't be there, which is what you want in this case.

Hope you will find this useful !

  - Chris

--
Chris Bedford
Founder & Lead Lackey
Build Lackey Labs:  http://buildlackey.com
Go Grails!: http://groovy.buildlackey.com