blob: a3aadb302b23f9ebd08c9650114fb94d4441f242 [file] [log] [blame]
------
WAR Manifest Customization
------
Pete Marvin King
------
2008-08-03
------
~~ Licensed to the Apache Software Foundation (ASF) under one
~~ or more contributor license agreements. See the NOTICE file
~~ distributed with this work for additional information
~~ regarding copyright ownership. The ASF licenses this file
~~ to you under the Apache License, Version 2.0 (the
~~ "License"); you may not use this file except in compliance
~~ with the License. You may obtain a copy of the License at
~~
~~ http://www.apache.org/licenses/LICENSE-2.0
~~
~~ Unless required by applicable law or agreed to in writing,
~~ software distributed under the License is distributed on an
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~~ KIND, either express or implied. See the License for the
~~ specific language governing permissions and limitations
~~ under the License.
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html
WAR Manifest Customization
The manifest can be customized by configuring the WAR Plugin's archiver. For full information on the different
configuration options available check the documentation for
{{{http://maven.apache.org/shared/maven-archiver/index.html}Maven Archiver}}.
*Generating a manifest classpath
Generating a manifest classpath for a WAR is similar to for a JAR, but there are a couple of slight differences since
you normally don't want a JAR in both the manifest classpath and the <<<WEB-INF/lib>>> directory. Customize the WAR
Plugin's archiver:
+--------------------+
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>
+--------------------+
Now, you can control which dependencies are included in <<<WEB-INF/lib>>> and in the manifest classpath by following
these examples. Maven will follow the transitive dependency tree until it gets to artifacts scoped as "provided".
<<Note:>> No way is shown how to include a dependency in <<<WEB-INF/lib>>> but not in the manifest classpath.
+--------------------+
<project>
...
<dependencies>
<dependency>
<groupId>org.foo</groupId>
<artifactId>bar-jar1</artifactId>
<version>${pom.version}</version>
<optional>true</optional>
<!-- goes in manifest classpath, but not included in WEB-INF/lib -->
</dependency>
<dependency>
<groupId>org.foo</groupId>
<artifactId>bar-jar2</artifactId>
<version>${pom.version}</version>
<!-- goes in manifest classpath, AND included in WEB-INF/lib -->
</dependency>
<dependency>
<groupId>org.foo</groupId>
<artifactId>bar-jar3</artifactId>
<version>${pom.version}</version>
<scope>provided</scope>
<!-- excluded from manifest classpath, and excluded from WEB-INF/lib -->
</dependency>
...
</dependencies>
...
</project>
+--------------------+
Check the {{{http://maven.apache.org/guides/mini/guide-manifest.html}Guide to Working with Manifests}} for more
examples.