Default Phase ( recommended )

package

Basic Usage

To explicitly invoke the goal

  m2 war:war

If the artifact package is declared as war

  <project>
     ...
     <groupId>com.somecompany.webapp<gropuId>
     <artifactId>webapp-service</artifactId>
     <version>0.0</version>
     <packaging>war</packaging>
     <name>Some Company Webapp Service</name>
     ...
  </project>

Specifying the package phase would achieve the same result

  mvn package

The manifest file can also be configured to contain user-defined values. see the Manifest Configuration Guide.

The maven descriptors can also be suppressed during war generation. see the Archive Configuration Guide.

Sample Configuration

Given the project structure

   /project_root
   /project_root/pom.xml
   /project_root/src/main/java/package/source
   /project_root/src/main/resource/someresource
   /project_root/src/main/webapp/WEB-INF/jsp/anotherwebsource    
   /project_root/src/main/webapp/WEB-INF/somewebsource  
   /project_root/src/main/webapp/websources

with pom.xml

   <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.somecompany.webapp<gropuId>
      <artifactId>webapp-service</artifactId>
      <version>0.0</version>
      <packaging>war</packaging>
      <name>Some Company Webapp Service</name>
      <dependencies>
         <dependency>
            <groupId>com.closed.package</groupId>
            <artifactId>runtimedependency</artifactId>
            <version>0.0</version>
            <scope>runtime<scope>
         </dependency>
         <dependency>
            <groupId>com.closed.package</groupId>
            <artifactId>normaldependency</artifactId>
            <version>0.0</version>
            <!-- if no scope is defined, it defaults to compile -->
         </dependency>
      </dependencies>     
   </project>   

executing the command

   mvn war:war

or

   mvn package

generates the war file "target/webapp-service-0.0.war".

The war file results to this

  webapp-service-0.0.war
       |_
         META-INF/MANIFEST.MF
         META-INF/maven/org.apache.maven.repository/maven-repository-webapp/pom.xml
         META-INF/maven/org.apache.maven.repository/maven-repository-webapp/pom.properties
         WEB-INF/lib/runtimedependency-0.0.jar
         WEB-INF/classes/<generated classes from "src/main/java">
         WEB-INF/jsp/anotherwebsource
         WEB-INF/somewebsource           
         websources                                                   

You might wonder why the other dependency is not included in WEB-INF/lib, only dependencies with a runtime scope are included in the war file.