## org.apache.tools.ant.taskdefs
Class War

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.MatchingTask
                  org.apache.tools.ant.taskdefs.Zip
                      org.apache.tools.ant.taskdefs.Jar
                          org.apache.tools.ant.taskdefs.War

All Implemented Interfaces:
  SelectorContainer

public class War
extends Jar

An extension of <jar> to create a WAR archive. Contains special treatment for files that should end up in the `WEB-INF/lib`, `WEB-INF/classes` or `WEB-INF` directories of the Web Application Archive.

(The War task is a shortcut for specifying the particular layout of a WAR file. The same thing can be accomplished by using the prefix and fullpath attributes of zipfilesets in a Zip or Jar task.)

The extended zipfileset element from the zip task (with attributes prefix, fullpath, and src) is available in the War task.

Since:
  Ant 1.2
Author:
  Stefan Bodewig
See Also:
  `Jar`

Nested Class Summary

Nested classes inherited from class org.apache.tools.ant.taskdefs.Jar
`Jar.FilesetManifestConfig`

Nested classes inherited from class org.apache.tools.ant.taskdefs.Zip
`Zip.ArchiveState, Zip.Duplicate, Zip.WhenEmpty`

Field Summary

Fields inherited from class org.apache.tools.ant.taskdefs.Zip
`addedDirs, archiveType, duplicate, emptyBehavior, entries, zipFile`

Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
`fileset, useDefaultExcludes`

Fields inherited from class org.apache.tools.ant.Task
`description, location, target, taskName, taskType, wrapper`

Fields inherited from class org.apache.tools.ant.ProjectComponent
`project`

Constructor Summary
`War()`

Method Summary
`void` `addClasses(ZipFileSet fs)` add files under WEB-INF/classes
`void` `addLib(ZipFileSet fs)` add files under WEB-INF/lib/
`void` `addWebinf(ZipFileSet fs)` files to add under WEB-INF;
`protected void` `cleanUp()` Make sure we don't think we already have a web.xml next time this task gets executed.
`protected void` `initZipOutputStream(ZipOutputStream zOut)` override of parent; validates configuration before initializing the output stream.
`void` `setWarfile(java.io.File warFile)` Deprecated. Use setDestFile(File) instead
`void` `setWebxml(java.io.File descr)` set the deployment descriptor to use (WEB-INF/web.xml); required unless `update=true`
`protected void` `zipFile(java.io.File file, ZipOutputStream zOut, java.lang.String vPath, int mode)` Overriden from Zip class to deal with web.xml

Methods inherited from class org.apache.tools.ant.taskdefs.Jar
`addConfiguredManifest, addMetainf, createEmptyZip, finalizeZipOutputStream, getResourcesToAdd, reset, setIndex, setJarfile, setManifest, setManifestEncoding, setWhenempty, zipFile`

Methods inherited from class org.apache.tools.ant.taskdefs.Zip
`addFileset, addParentDirs, addResources, addZipfileset, addZipGroupFileset, execute, getDestFile, getEncoding, grabResources, isAddingNewFiles, isCompress, isEmpty, isInUpdateMode, setBasedir, setCompress, setDestFile, setDuplicate, setEncoding, setFile, setFilesonly, setUpdate, setZipfile, zipDir`

Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask

`addAnd, addContains, addCustom, addDate, addDepend, addDepth, addFilename, addMajority, addNone, addNot, addOr, addPresent, addSelector, addSize, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems`

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

Methods inherited from class org.apache.tools.ant.ProjectComponent
`getProject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### War

    public War()

Method Detail

### setWarfile

    public void setWarfile(java.io.File warFile)

  Deprecated. Use setDestFile(File) instead

  Deprecated name of the file to create -use `destfile` instead.

### setWebxml

    public void setWebxml(java.io.File descr)

  set the deployment descriptor to use (WEB-INF/web.xml); required unless `update=true`

### addLib

    public void addLib(ZipFileSet fs)

  add files under WEB-INF/lib/

### addClasses

    public void addClasses(ZipFileSet fs)

  add files under WEB-INF/classes

### addWebinf

    public void addWebinf(ZipFileSet fs)

  files to add under WEB-INF;

### initZipOutputStream

    protected void initZipOutputStream(ZipOutputStream zOut)
                                throws java.io.IOException,
                                       BuildException

  override of parent; validates configuration before initializing the output stream.

  Overrides:
    `initZipOutputStream` in class `Jar`
  Throws:
    `java.io.IOException`
    `BuildException`

### zipFile

    protected void zipFile(java.io.File file,
                           ZipOutputStream zOut,
                           java.lang.String vPath,
                           int mode)
                    throws java.io.IOException

  Overriden from Zip class to deal with web.xml

  Overrides:
    `zipFile` in class `Zip`
  Parameters:
    `file` - the file to add to the archive
    `zOut` - the stream to write to
    `vPath` - the name this entry shall have in the archive
    `mode` - the Unix permissions to set.
  Throws:
    `java.io.IOException`

### cleanUp

    protected void cleanUp()

  Make sure we don't think we already have a web.xml next time this task gets executed.

  Overrides:
    `cleanUp` in class `Jar`
  See Also:
    `Zip.cleanUp()`

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.