Maven war plugin

This plugin builds your war (webapp).

Filtered resources

I wanted to add the build number to the final war. Filtering is a build step where placeholders will be replaced with dynamic values at build time.

Create a parallel webapp directory

Create another directory src/main/webapp-filtered. We make this separate to the default src/main/webapp directory because that usually contains binary files should not be filtered.

Create a build.json

Add the file src/main/webapp-filtered/build.json. This is a text file with contents:

  "build": "${build.number}"

Add config to pom.xml


The above tells maven to include the src/main/webapp-filtered directory when building the webapp, and also to do filtering at build time for files under this directory.

If you are using IntelliJ, then version 12 or higher should recognise this new directory


mvn clean install -Dbuild.number=35

Verify that the build.json in your target directory contains the build number 35.

Published: Sunday, 15 December 2013