war:war

Full name:

org.apache.maven.plugins:maven-war-plugin:3.4.1-SNAPSHOT:war

Description:

Build a WAR file.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: compile+runtime.
  • The goal is thread-safe and supports parallel builds.
  • Binds by default to the lifecycle phase: package.

Required Parameters

Name Type Since Description
<outputDirectory> String - The directory for the generated WAR.
Default value is: ${project.build.directory}.
<warSourceDirectory> File - Single directory for extra files to include in the WAR. This is where you place your JSP files.
Default value is: ${basedir}/src/main/webapp.
<webappDirectory> File - The directory where the webapp is built.
Default value is: ${project.build.directory}/${project.build.finalName}.
<workDirectory> File - Directory to unpack dependent WARs into if needed.
Default value is: ${project.build.directory}/war/work.

Optional Parameters

Name Type Since Description
<archive> MavenArchiveConfiguration - The archive configuration to use. See Maven Archiver Reference.
<archiveClasses> boolean 2.0.1 Whether a JAR file will be created for the classes in the webapp. Using this optional configuration parameter will make the compiled classes to be archived into a JAR file in /WEB-INF/lib/ and the classes directory will then be excluded from the webapp /WEB-INF/classes/.
Default value is: false.
<attachClasses> boolean 2.1-alpha-2 Whether classes (that is the content of the WEB-INF/classes directory) should be attached to the project as an additional artifact.

By default the classifier for the additional artifact is 'classes'. You can change it with the <classesClassifier>someclassifier</classesClassifier> parameter.

If this parameter true, another project can depend on the classes by writing something like:

<dependency>
  <groupId>myGroup</groupId>
  <artifactId>myArtifact</artifactId>
  <version>myVersion</myVersion>
  <classifier>classes</classifier>
</dependency>


Default value is: false.
<classesClassifier> String 2.1-alpha-2 The classifier to use for the attached classes artifact.
Default value is: classes.
<classifier> String - Classifier to add to the generated WAR. If given, the artifact will be an attachment instead. The classifier will not be applied to the JAR file of the project - only to the WAR file.
<containerConfigXML> File - The path to a configuration file for the servlet container. Note that the file name may be different for different servlet containers. Apache Tomcat uses a configuration file named context.xml. The file will be copied to the META-INF directory.
<delimiters> LinkedHashSet<String> 3.0.0

Set of delimiters for expressions to filter within the resources. These delimiters are specified in the form 'beginToken*endToken'. If no '*' is given, the delimiter is assumed to be the same for start and end.

So, the default filtering delimiters might be specified as:

<delimiters>
  <delimiter>${*}</delimiter>
  <delimiter>@</delimiter>
</delimiters>

Since the '@' delimiter is the same on both ends, we don't need to specify '@*@' (though we can).


<dependentWarExcludes> String - The comma separated list of tokens to exclude when doing a WAR overlay. Default is Overlay.DEFAULT_EXCLUDES
<dependentWarIncludes> String - The comma separated list of tokens to include when doing a WAR overlay. Default is Overlay.DEFAULT_INCLUDES
<escapedBackslashesInFilePath> boolean 2.1-alpha-2 To escape interpolated values with Windows path c:\foo\bar will be replaced with c:\\foo\\bar.
Default value is: false.
<escapeString> String 2.1-beta-1 Expression preceded with this String won't be interpolated. \${foo} will be replaced with ${foo}.
<failOnMissingWebXml> Boolean 2.1-alpha-2 Whether or not to fail the build if the web.xml file is missing. Set to false if you want your WAR built without a web.xml file. This may be useful if you are building an overlay that has no web.xml file.

Starting with 3.1.0, this property defaults to false if the project depends on the Servlet 3.0 API or newer.


<filteringDeploymentDescriptors> boolean 2.1-alpha-2 To filter deployment descriptors. Disabled by default.
Default value is: false.
<filters> List<String> - Filters (property files) to include during the interpolation of the pom.xml.
<includeEmptyDirectories> boolean 2.4 (no description)
Default value is: false.
<nonFilteredFileExtensions> List<String> 2.1-alpha-2 A list of file extensions that should not be filtered. Will be used when filtering webResources and overlays.
<outdatedCheckPath> String 3.3.1 Path prefix for resources that will be checked against outdated content. Starting with 3.3.2, if a value of "/" is specified the entire webappDirectory will be checked, i.e. the "/" signifies "root".
Default value is: WEB-INF/lib/.
<outputFileNameMapping> String 2.1-alpha-1 The file name mapping to use when copying libraries and TLDs. If no file mapping is set (default) the files are copied with their standard names.
<outputTimestamp> String 3.3.0 Timestamp for reproducible output archive entries, either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).
Default value is: ${project.build.outputTimestamp}.
<overlays> List<Overlay> 2.1-alpha-1 The overlays to apply. Each <overlay> element may contain:
  • id (defaults to currentBuild)
  • groupId (if this and artifactId are null, then the current project is treated as its own overlay)
  • artifactId (see above)
  • classifier
  • type
  • includes (a list of string patterns)
  • excludes (a list of string patterns)
  • filtered (defaults to false)
  • skip (defaults to false)
  • targetPath (defaults to root of webapp structure)

<packagingExcludes> String 2.1-alpha-2 The comma separated list of tokens to exclude from the WAR before packaging. This option may be used to implement the skinny WAR use case. Note that you can use the Java Regular Expressions engine to include and exclude specific pattern using the expression %regex[]. Hint: read the about (?!Pattern).
<packagingIncludes> String 2.1-beta-1 The comma separated list of tokens to include in the WAR before packaging. By default everything is included. This option may be used to implement the skinny WAR use case. Note that you can use the Java Regular Expressions engine to include and exclude specific pattern using the expression %regex[].
<primaryArtifact> boolean - Whether this is the main artifact being built. Set to false if you don't want to install or deploy it to the local repository instead of the default one in an execution.
Default value is: true.
<propertiesEncoding> String 3.4.0 The character encoding to use when reading and writing filtered properties files. If not specified, it will default to the value of the "resourceEncoding" parameter.
<recompressZippedFiles> boolean 2.3 Indicates if zip archives (jar,zip etc) being added to the war should be compressed again. Compressing again can result in smaller archive size, but gives noticeably longer execution time.
Default value is: true.
<resourceEncoding> String 2.3 The encoding to use when copying filtered web resources.
Default value is: ${project.build.sourceEncoding}.
<skip> boolean 3.0.0 You can skip the execution of the plugin if you need to. Its use is NOT RECOMMENDED, but quite convenient on occasion.
Default value is: false.
User property is: maven.war.skip.
<supportMultiLineFiltering> boolean 2.4 Stop searching endToken at the end of line
Default value is: false.
<useDefaultDelimiters> boolean 3.0.0 Use default delimiters in addition to custom delimiters, if any.
Default value is: true.
<useJvmChmod> boolean 2.4 use jvmChmod rather that cli chmod and forking process
Default value is: true.
<warSourceExcludes> String - The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.
<warSourceIncludes> String - The comma separated list of tokens to include when copying the content of the warSourceDirectory.
Default value is: **.
<webResources> Resource[] - The list of webResources we want to transfer.
<webXml> File - The path to the web.xml file to use.

Parameter Details

<archive>

The archive configuration to use. See Maven Archiver Reference.
  • Type: org.apache.maven.archiver.MavenArchiveConfiguration
  • Required: No

<archiveClasses>

Whether a JAR file will be created for the classes in the webapp. Using this optional configuration parameter will make the compiled classes to be archived into a JAR file in /WEB-INF/lib/ and the classes directory will then be excluded from the webapp /WEB-INF/classes/.
  • Type: boolean
  • Since: 2.0.1
  • Required: No
  • Default: false

<attachClasses>

Whether classes (that is the content of the WEB-INF/classes directory) should be attached to the project as an additional artifact.

By default the classifier for the additional artifact is 'classes'. You can change it with the <classesClassifier>someclassifier</classesClassifier> parameter.

If this parameter true, another project can depend on the classes by writing something like:

<dependency>
  <groupId>myGroup</groupId>
  <artifactId>myArtifact</artifactId>
  <version>myVersion</myVersion>
  <classifier>classes</classifier>
</dependency>

  • Type: boolean
  • Since: 2.1-alpha-2
  • Required: No
  • Default: false

<classesClassifier>

The classifier to use for the attached classes artifact.
  • Type: java.lang.String
  • Since: 2.1-alpha-2
  • Required: No
  • Default: classes

<classifier>

Classifier to add to the generated WAR. If given, the artifact will be an attachment instead. The classifier will not be applied to the JAR file of the project - only to the WAR file.
  • Type: java.lang.String
  • Required: No

<containerConfigXML>

The path to a configuration file for the servlet container. Note that the file name may be different for different servlet containers. Apache Tomcat uses a configuration file named context.xml. The file will be copied to the META-INF directory.
  • Type: java.io.File
  • Required: No

<delimiters>

Set of delimiters for expressions to filter within the resources. These delimiters are specified in the form 'beginToken*endToken'. If no '*' is given, the delimiter is assumed to be the same for start and end.

So, the default filtering delimiters might be specified as:

<delimiters>
  <delimiter>${*}</delimiter>
  <delimiter>@</delimiter>
</delimiters>

Since the '@' delimiter is the same on both ends, we don't need to specify '@*@' (though we can).

  • Type: java.util.LinkedHashSet<java.lang.String>
  • Since: 3.0.0
  • Required: No

<dependentWarExcludes>

The comma separated list of tokens to exclude when doing a WAR overlay. Default is Overlay.DEFAULT_EXCLUDES
  • Type: java.lang.String
  • Required: No

<dependentWarIncludes>

The comma separated list of tokens to include when doing a WAR overlay. Default is Overlay.DEFAULT_INCLUDES
  • Type: java.lang.String
  • Required: No

<escapedBackslashesInFilePath>

To escape interpolated values with Windows path c:\foo\bar will be replaced with c:\\foo\\bar.
  • Type: boolean
  • Since: 2.1-alpha-2
  • Required: No
  • Default: false

<escapeString>

Expression preceded with this String won't be interpolated. \${foo} will be replaced with ${foo}.
  • Type: java.lang.String
  • Since: 2.1-beta-1
  • Required: No

<failOnMissingWebXml>

Whether or not to fail the build if the web.xml file is missing. Set to false if you want your WAR built without a web.xml file. This may be useful if you are building an overlay that has no web.xml file.

Starting with 3.1.0, this property defaults to false if the project depends on the Servlet 3.0 API or newer.

  • Type: java.lang.Boolean
  • Since: 2.1-alpha-2
  • Required: No

<filteringDeploymentDescriptors>

To filter deployment descriptors. Disabled by default.
  • Type: boolean
  • Since: 2.1-alpha-2
  • Required: No
  • Default: false

<filters>

Filters (property files) to include during the interpolation of the pom.xml.
  • Type: java.util.List<java.lang.String>
  • Required: No

<includeEmptyDirectories>

(no description)
  • Type: boolean
  • Since: 2.4
  • Required: No
  • Default: false

<nonFilteredFileExtensions>

A list of file extensions that should not be filtered. Will be used when filtering webResources and overlays.
  • Type: java.util.List<java.lang.String>
  • Since: 2.1-alpha-2
  • Required: No

<outdatedCheckPath>

Path prefix for resources that will be checked against outdated content. Starting with 3.3.2, if a value of "/" is specified the entire webappDirectory will be checked, i.e. the "/" signifies "root".
  • Type: java.lang.String
  • Since: 3.3.1
  • Required: No
  • Default: WEB-INF/lib/

<outputDirectory>

The directory for the generated WAR.
  • Type: java.lang.String
  • Required: Yes
  • Default: ${project.build.directory}

<outputFileNameMapping>

The file name mapping to use when copying libraries and TLDs. If no file mapping is set (default) the files are copied with their standard names.
  • Type: java.lang.String
  • Since: 2.1-alpha-1
  • Required: No

<outputTimestamp>

Timestamp for reproducible output archive entries, either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).
  • Type: java.lang.String
  • Since: 3.3.0
  • Required: No
  • Default: ${project.build.outputTimestamp}

<overlays>

The overlays to apply. Each <overlay> element may contain:
  • id (defaults to currentBuild)
  • groupId (if this and artifactId are null, then the current project is treated as its own overlay)
  • artifactId (see above)
  • classifier
  • type
  • includes (a list of string patterns)
  • excludes (a list of string patterns)
  • filtered (defaults to false)
  • skip (defaults to false)
  • targetPath (defaults to root of webapp structure)

<packagingExcludes>

The comma separated list of tokens to exclude from the WAR before packaging. This option may be used to implement the skinny WAR use case. Note that you can use the Java Regular Expressions engine to include and exclude specific pattern using the expression %regex[]. Hint: read the about (?!Pattern).
  • Type: java.lang.String
  • Since: 2.1-alpha-2
  • Required: No

<packagingIncludes>

The comma separated list of tokens to include in the WAR before packaging. By default everything is included. This option may be used to implement the skinny WAR use case. Note that you can use the Java Regular Expressions engine to include and exclude specific pattern using the expression %regex[].
  • Type: java.lang.String
  • Since: 2.1-beta-1
  • Required: No

<primaryArtifact>

Whether this is the main artifact being built. Set to false if you don't want to install or deploy it to the local repository instead of the default one in an execution.
  • Type: boolean
  • Required: No
  • Default: true

<propertiesEncoding>

The character encoding to use when reading and writing filtered properties files. If not specified, it will default to the value of the "resourceEncoding" parameter.
  • Type: java.lang.String
  • Since: 3.4.0
  • Required: No

<recompressZippedFiles>

Indicates if zip archives (jar,zip etc) being added to the war should be compressed again. Compressing again can result in smaller archive size, but gives noticeably longer execution time.
  • Type: boolean
  • Since: 2.3
  • Required: No
  • Default: true

<resourceEncoding>

The encoding to use when copying filtered web resources.
  • Type: java.lang.String
  • Since: 2.3
  • Required: No
  • Default: ${project.build.sourceEncoding}

<skip>

You can skip the execution of the plugin if you need to. Its use is NOT RECOMMENDED, but quite convenient on occasion.
  • Type: boolean
  • Since: 3.0.0
  • Required: No
  • User Property: maven.war.skip
  • Default: false

<supportMultiLineFiltering>

Stop searching endToken at the end of line
  • Type: boolean
  • Since: 2.4
  • Required: No
  • Default: false

<useDefaultDelimiters>

Use default delimiters in addition to custom delimiters, if any.
  • Type: boolean
  • Since: 3.0.0
  • Required: No
  • Default: true

<useJvmChmod>

use jvmChmod rather that cli chmod and forking process
  • Type: boolean
  • Since: 2.4
  • Required: No
  • Default: true

<warSourceDirectory>

Single directory for extra files to include in the WAR. This is where you place your JSP files.
  • Type: java.io.File
  • Required: Yes
  • Default: ${basedir}/src/main/webapp

<warSourceExcludes>

The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.
  • Type: java.lang.String
  • Required: No

<warSourceIncludes>

The comma separated list of tokens to include when copying the content of the warSourceDirectory.
  • Type: java.lang.String
  • Required: No
  • Default: **

<webappDirectory>

The directory where the webapp is built.
  • Type: java.io.File
  • Required: Yes
  • Default: ${project.build.directory}/${project.build.finalName}

<webResources>

The list of webResources we want to transfer.
  • Type: org.apache.maven.model.Resource[]
  • Required: No

<webXml>

The path to the web.xml file to use.
  • Type: java.io.File
  • Required: No

<workDirectory>

Directory to unpack dependent WARs into if needed.
  • Type: java.io.File
  • Required: Yes
  • Default: ${project.build.directory}/war/work