Apache Ant War Task

Ant WAR (Web Archive) is an extension of Java Archive file. It is consist of library, classes etc and store into WEB-INF/lib, WEB-INF/classes folders.

Apache Ant WAR Attributes

AttributeDescriptionRequired
destfileName of the WAR to create.Yes
webxmlServlet configuration descriptorYes
basedirDirectory from which to jar the files.No
compressStore and compress data
encodingIt is used to specify encoding.No
filesonlyStores only filesNo
includesInclude a list of files.No
excludesExcludes a list of files.No
updateUpdate destination file even when present.No

Apache Ant WAR Task Nested Elements

lib

This element specifies a fileset. All the files are located in WEB-INF/lib folder of the created WAR.

classes

This element specifies a fileset of class files. After creating war, all the classes are located into WEB-INF/classes folder.

webinf

This nested element specifies a fileset. All the files are located into WEB-INF directory.

Apache Ant War Task Example

The above code will create a myapp.war file which has a file structure given below. The above code will create a myapp.war file which has a file structure given below.





Latest Courses