Apache Maven 1.x has reached its end of life, and is no longer supported. For more information, see the announcement. Users are encouraged to migrate to the current version of Apache Maven.

Maven War Plugin

This plug-in provides the ability to generate either a deployed webapp or a webapp packaged as a WAR file.

Bundling dependencies

If you need to add extra dependencies in the web application, there are two properties you can use.

war.bundleThis property includes the dependency in /WEB-INF/lib
war.target.pathThis bundles the dependency in the path specified relative to the base of the web application.
war.target.filenameThis specifies the filename of the the dependency in the path specified by the war.target.path property.

For example, the following adds commons-lang to /WEB-INF/lib, myApplet to the /applets directory and anotherApplet in /applets/another-applet.jar.

  <dependency>
    <id>commons-lang</id>
    <version>2.0</version>
    <properties>
      <war.bundle>true</war.bundle>
    </properties>
  </dependency>

  <dependency>
    <id>myApplet</id>
    <version>1.4</version>
    <properties>
      <war.target.path>applets</war.target.path>
    </properties>
  </dependency>

   <dependency>
    <id>anotherApplet</id>
    <version>1.2</version>
    <properties>
      <war.target.path>applets</war.target.path>
      <war.target.filename>another-applet.jar</war.target.filename>
    </properties>
  </dependency>

Filtering web.xml

If you need to copy the web.xml file in order to replace some filter tokens or simply perform some custom modification to it, simply write a pre-goal to the war:war-resources goal in which you perform the manipulation. Then set the maven.war.webxml property to point to your modified web.xml.