Apache Ant - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

ANT Packaging

ANT Packaging

shape Introduction

The current chapter explains about ANT Packaging. In ANT Packaging, JAR and WAR files are zipped using JAVA jar tool. ANT Packaging chapter explains about:
  • WAR Structure
  • Making of WAR File and packaging

shape Description

Before building WAR files, the JUnit test process has to be completed successfully. The process of testing was explained in the previous chapter-JUnit Test. WAR File is the combination of jar file, web.xml file and the basic structure will be as follows.

shape Further Process

One can also place the third party jar files in WEB-INF/lib directory using lib attribute. However, there are no such jar files and hence it remains empty. The destination file can be given any name and must be placed in the build directory.webxml attribute defines the location of Web.xml file, which is in etc directory. All the HTML and JSP files are included using the fileset tag as discussed earlier. zipfileset packages all the files like war files, images, and many more. After including all the files, the file is ready to deploy into the server.

shape Examples

[java] <target name="war" depends="test" unless="testsFailed"> <war destfile="${build.dir}/${war.name}" webxml="${etc.dir}/web.xml"> <fileset dir="html"/> <fileset dir="jsp"/> <lib dir="libs"/> <classes dir="${build.dir.classes}"> <include name="**/*.class" /> <exclude name="**/*Test*.class" /> </classes> <zipfileset dir="images" prefix="images"/> </war> </target> [/java]

Summary

shape Key Points

  • WAR is an extension to JAR.
  • fileset tag includes the html, jsp and javascript files.
  • zipfileset packages the required files.