org.apache.tools.ant.taskdefs

Class War

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

See Also: Jar

UNKNOWN: category="packaging"

Constructor Summary
War()
Constructor for the War Task.
Method Summary
voidaddClasses(ZipFileSet fs)
add files under WEB-INF/classes
voidaddLib(ZipFileSet fs)
add files under WEB-INF/lib/
voidaddWebinf(ZipFileSet fs)
files to add under WEB-INF;
protected voidcleanUp()
Make sure we don't think we already have a web.xml next time this task gets executed.
protected voidinitZipOutputStream(ZipOutputStream zOut)
override of parent; validates configuration before initializing the output stream.
voidsetNeedxmlfile(boolean needxmlfile)
Set the policy on the web.xml file, that is, whether or not it is needed
voidsetWarfile(File warFile)
Deprecated name of the file to create -use destfile instead.
voidsetWebxml(File descr)
set the deployment descriptor to use (WEB-INF/web.xml); required unless update=true
protected voidzipFile(File file, ZipOutputStream zOut, String vPath, int mode)
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

Constructor Detail

War

public War()
Constructor for the War Task.

Method Detail

addClasses

public void addClasses(ZipFileSet fs)
add files under WEB-INF/classes

Parameters: fs the zip file set to add

addLib

public void addLib(ZipFileSet fs)
add files under WEB-INF/lib/

Parameters: fs the zip file set to add

addWebinf

public void addWebinf(ZipFileSet fs)
files to add under WEB-INF;

Parameters: fs the zip file set to add

cleanUp

protected void cleanUp()
Make sure we don't think we already have a web.xml next time this task gets executed.

initZipOutputStream

protected void initZipOutputStream(ZipOutputStream zOut)
override of parent; validates configuration before initializing the output stream.

Parameters: zOut the zip output stream

Throws: IOException on output error BuildException if invalid configuration

setNeedxmlfile

public void setNeedxmlfile(boolean needxmlfile)
Set the policy on the web.xml file, that is, whether or not it is needed

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

setWarfile

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 the destination file

UNKNOWN: ignore="true"

setWebxml

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

Parameters: descr the deployment descriptor file

zipFile

protected void zipFile(File file, ZipOutputStream zOut, String vPath, int mode)
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 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: IOException on output error