------ Usage ------ Pete Marvin King ------ 2010-08-15 ------ ~~ 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 Usage There are 4 ways to use the WAR Plugin: * using the <<>> phase with the project package type as <<>> * invocation of the <<>> goal * invocation of the <<>> goal * invocation of the <<>> goal [] <> When using the <<>> goals it is assumed that the <<>> phase is already done. The WAR Plugin is not responsible for compiling the java sources or copying the resources. To handle archiving this version of Maven WAR Plugin uses {{{http://maven.apache.org/shared/maven-archiver/index.html}Maven Archiver}} ${mavenArchiverVersion}. To handle filtering this version of Maven WAR Plugin uses {{{http://maven.apache.org/shared/maven-filtering/index.html}Maven Filtering}} ${mavenFilteringVersion}. *Using the <<>> phase with the project package type as war / invocation of the <<>> goal This is the normal way of using the WAR Plugin. To illustrate, here's the <<>> for our project: +----------+ ... com.example.projects documentedproject war 1.0-SNAPSHOT Documented Project http://example.com ... +----------+ The project's structure looks like this: +----------+ |-- pom.xml `-- src `-- main |-- java | `-- com | `-- example | `-- projects | `-- SampleAction.java |-- resources | `-- images | `-- sampleimage.jpg `-- webapp |-- WEB-INF | `-- web.xml |-- index.jsp `-- jsp `-- websource.jsp +----------+ Invoking +----------+ mvn package +----------+ or +----------+ mvn compile war:war +----------+ will generate the WAR file <<>>. Here are the contents of that WAR file: +----------+ documentedproject-1.0-SNAPSHOT.war |-- META-INF | |-- MANIFEST.MF | `-- maven | `-- com.example.projects | `-- documentedproject | |-- pom.properties | `-- pom.xml |-- WEB-INF | |-- classes | | |-- com | | | `-- example | | | `-- projects | | | `-- SampleAction.class | | `-- images | | `-- sampleimage.jpg | `-- web.xml |-- index.jsp `-- jsp `-- websource.jsp +----------+ *Invocation of <<>> goal To speed up testing during the developement phase, <<>> can be used to generate the WAR in exploded form. Use the same project as above and invoke: +----------+ mvn compile war:exploded +----------+ This will generate an exploded version of the WAR in <<>>. The contents of that directory looks like this: +----------+ documentedproject-1.0-SNAPSHOT |-- META-INF |-- WEB-INF | |-- classes | | |-- com | | | `-- example | | | `-- projects | | | `-- SampleAction.class | | `-- images | | `-- sampleimage.jpg | `-- web.xml |-- index.jsp `-- jsp `-- websource.jsp +----------+ The default directory for the exploded WAR is <<>>>. The <<>> is usually in the form of <<<\-\>>>. This default directory can be overridden by specifying the <<>> parameter. +-------+ ... org.apache.maven.plugins maven-war-plugin ${project.version} /sample/servlet/container/deploy/directory ... +-------+ *Invocation of <<>> goal Another variation of <<>> is <<>>. With <<>> the exploded WAR is created in the webapp source, which defaults to <<>>. Use our sample project above, and invoke: +----------+ mvn compile war:inplace +----------+ This will result in: +----------+ |-- pom.xml |-- src | `-- main | |-- java | | `-- com | | `-- example | | `-- projects | | `-- SampleAction.java | |-- resources | | `-- images | | `-- sampleimage.jpg | `-- webapp | |-- META-INF | |-- WEB-INF | | |-- classes | | | |-- com | | | | `-- example | | | | `-- projects | | | | `-- SampleAction.class | | | `-- images | | | `-- sampleimage.jpg | | `-- web.xml | |-- index.jsp | `-- jsp | `-- websource.jsp `-- target `-- classes |-- com | `-- example | `-- projects | `-- SampleAction.class `-- images `-- sampleimage.jpg +----------+