# The War Plugin

The War plugin extends the Java plugin to add support for assembling web application WAR files. It disables the default JAR archive generation of the Java plugin and adds a default WAR archive task.

## Usage

To use the War plugin, include in your build script:

## Tasks

The War plugin adds the following tasks to the project.

## War plugin - tasks

Task name | Depends on | Type | Description
`war` | `compile` |  | Assembles the application WAR file.

The War plugin adds the following dependencies to tasks added by the Java plugin.

## War plugin - additional task dependencies

Task name | Depends on
assemble | war

### War plugin - tasks

## Project layout

## War plugin - project layout

Directory | Meaning
`src/main/webapp` | Web application sources

## Dependency management

The War plugin adds two dependency configurations: `providedCompile` and `providedRuntime`. Those configurations have the same scope as the respective `compile` and `runtime` configurations, except that they are not added to the WAR archive. It is important to note that those `provided` configurations work transitively. Let's say you add `commons-httpclient:commons-httpclient:3.0` to any of the provided configurations. This dependency has a dependency on `commons-codec`. This means neither `httpclient` nor `commons-codec` is added to your WAR, even if `commons-codec` were an explicit dependency of your `compile` configuration. If you don't want this transitive behavior, simply declare your `provided` dependencies like `commons-httpclient:commons-httpclient:3.0@jar`.

## Convention properties

## War plugin - directory properties

Property name | Type | Default value | Description
`webAppDirName` | `String` | `src/main/webapp` | The name of the web application source directory, relative to the project directory.
`webAppDir` | `File` (read-only) | ``projectDir`/`webAppDirName`` | The web application source directory.

These properties are provided by a convention object.

## War

The default behavior of the War task is to copy the content of `src/main/webapp` to the root of the archive. Your `webapp` directory may of course contain a `WEB-INF` sub-directory, which again may contain a `web.xml` file. Your compiled classes are compiled to `WEB-INF/classes`. All the dependencies of the `runtime`

The `runtime` configuration extends the `compile` configuration.

configuration are copied to `WEB-INF/lib`.

Have also a look at .

## Customizing

Here is an example with the most important customization options:

Of course one can configure the different file-sets with a closure to define excludes and includes.