Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class War

extends Jar
Class Inheritance
Imports
java.io.File, .IOException, org.apache.tools.ant.BuildException, .Project, org.apache.tools.ant.types.ZipFileSet, org.apache.tools.ant.util.FileUtils, org.apache.tools.zip.ZipOutputStream

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
See Also
Jar

Field Summary

Modifier and TypeField and Description
private File
private File
deploymentDescriptor

our web.xml deployment descriptor

private static final FileUtils
private boolean
needxmlfile

flag set if the descriptor is added

private static final String
XML_DESCRIPTOR_PATH

path to web.xml file

Constructor Summary

AccessConstructor and Description
public
War()

Constructor for the War Task.

Method Summary

Modifier and TypeMethod and Description
public void
addClasses(ZipFileSet
the zip file set to add
fs
)

add files under WEB-INF/classes

public void
addLib(ZipFileSet
the zip file set to add
fs
)

add files under WEB-INF/lib/

public void
addWebinf(ZipFileSet
the zip file set to add
fs
)

files to add under WEB-INF;

protected void
cleanUp()

Overrides org.apache.tools.ant.taskdefs.Jar.cleanUp.

Make sure we don't think we already have a web.xml next time this task gets executed.
protected void
initZipOutputStream(ZipOutputStream
the zip output stream
zOut
)

Overrides org.apache.tools.ant.taskdefs.Jar.initZipOutputStream.

override of parent; validates configuration before initializing the output stream.
public void
setNeedxmlfile(boolean
whether a web.xml file is needed. Default: true
needxmlfile
)

Set the policy on the web.xml file, that is, whether or not it is needed

public void
setWarfile(File
the destination file
warFile
)

Deprecated since 1.5.x. Use setDestFile(File) instead
Deprecated name of the file to create -use destfile instead.
public void
setWebxml(File
the deployment descriptor file
descr
)

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

protected void
zipFile(File
the file to add to the archive
file
,
ZipOutputStream
the stream to write to
zOut
,
String
the name this entry shall have in the archive
vPath
,
int
the Unix permissions to set.
mode
)

Overrides org.apache.tools.ant.taskdefs.Zip.zipFile.

Overridden from Zip class to deal with web.xml Here are cases that can arise -not a web.xml file : add -first web.xml : add, remember we added it -same web.xml again: skip -alternate web.xml : warn and skip
Inherited from org.apache.tools.ant.taskdefs.Jar:
addConfiguredIndexJarsaddConfiguredIndexJarsMapperaddConfiguredManifestaddConfiguredServiceaddMetainfcreateEmptyZipfinalizeZipOutputStreamfindJarNamegetIndexJarsMappergetResourcesToAddgrabFilesAndDirsresetsetFilesetmanifestsetFlattenAttributessetIndexsetIndexMetaInfsetJarfilesetManifestsetManifestEncodingsetMergeClassPathAttributessetStrictsetWhenemptysetWhenmanifestonlywriteIndexLikeListzipFile

Field Detail

addedWebXmlFileback to summary
private File addedWebXmlFile
deploymentDescriptorback to summary
private File deploymentDescriptor

our web.xml deployment descriptor

FILE_UTILSback to summary
private static final FileUtils FILE_UTILS

Hides org.apache.tools.ant.taskdefs.Zip.FILE_UTILS.

needxmlfileback to summary
private boolean needxmlfile

flag set if the descriptor is added

XML_DESCRIPTOR_PATHback to summary
private static final String XML_DESCRIPTOR_PATH

path to web.xml file

Constructor Detail

Warback to summary
public War()

Constructor for the War Task.

Method Detail

addClassesback to summary
public void addClasses(ZipFileSet fs)

add files under WEB-INF/classes

Parameters
fs:ZipFileSet

the zip file set to add

addLibback to summary
public void addLib(ZipFileSet fs)

add files under WEB-INF/lib/

Parameters
fs:ZipFileSet

the zip file set to add

addWebinfback to summary
public void addWebinf(ZipFileSet fs)

files to add under WEB-INF;

Parameters
fs:ZipFileSet

the zip file set to add

cleanUpback to summary
protected void cleanUp()

Overrides org.apache.tools.ant.taskdefs.Jar.cleanUp.

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

Annotations
@Override
initZipOutputStreamback to summary
protected void initZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException

Overrides org.apache.tools.ant.taskdefs.Jar.initZipOutputStream.

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

Parameters
zOut:ZipOutputStream

the zip output stream

Annotations
@Override
Exceptions
IOException:
on output error
BuildException:
if invalid configuration
setNeedxmlfileback to summary
public void setNeedxmlfile(boolean needxmlfile)

Set the policy on the web.xml file, that is, whether or not it is needed

Parameters
needxmlfile:boolean

whether a web.xml file is needed. Default: true

setWarfileback to summary
public void setWarfile(File warFile)

Deprecated

since 1.5.x. Use setDestFile(File) instead

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

Parameters
warFile:File

the destination file

Annotations
@Deprecated
setWebxmlback to summary
public void setWebxml(File descr)

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

Parameters
descr:File

the deployment descriptor file

zipFileback to summary
protected void zipFile(File file, ZipOutputStream zOut, String vPath, int mode) throws IOException

Overrides org.apache.tools.ant.taskdefs.Zip.zipFile.

Overridden from Zip class to deal with web.xml Here are cases that can arise -not a web.xml file : add -first web.xml : add, remember we added it -same web.xml again: skip -alternate web.xml : warn and skip

Parameters
file:File

the file to add to the archive

zOut:ZipOutputStream

the stream to write to

vPath:String

the name this entry shall have in the archive

mode:int

the Unix permissions to set.

Annotations
@Override
Exceptions
IOException:
on output error