Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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).


Here's an example of how to this.

  • Create a simple web application using maven archetype:
  • mvn archetype:generate -DarchetypeGroupId=org.codehaus.groovy.maven.archetypes -DartifactId=example -Dpackage=com.lackey
  • choose option 18 (simple web app -- this will generate a simple web app project).
  • cd example
  • create a file src/main/webapp/
  • run: mvn package
  • notice you have a file target/example/ -- this means will end up in your .war.
  • now change your pom file to include the following directives in the <build> block:
  • run: mvn package (again)

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

  • No labels