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

ANT Deploy

ANT Deploy

shape Introduction

Deployment is a process of moving an activity/task into the server such that it will work in real-time. In order to deploy, project has to be packed using zipfileset. The following topics are covered in ANT Deploy chapter:
  • Introduction to deployment
  • copy task
  • FTP server connection

shape Description

After packing, the war file is ready to deploy. ANT Deploy can be done in various ways. Normally, the war file can be copied into other machine using the copy task, if it is a local machine.

shape Conceptual figure

shape Example

Code for deploying using copy task [java] <target name="deploy" depends="war" unless="testsFailed"> <copy file="${build.dir}/${war.name}" to dir="${deploy.dir}"/> </target> [/java]

shape Further Process

But now, deploying must be done to a QA machine, which is an integration test machine and QA machine can be accessed via FTP. In the below example, server attribute is the remote machine hostname for which the transfer of file will be done. Remotedir defines the ftp task destination directory. Servers and FTP clients use binary modes to the files like the zip file in the project. Verbose gives an extra information about the transfer of file. Passive has to be set to yes to get through the firewall. Now, the FTP server connection has been set. Then, the server has to be instructed what to transfer. The fileset tags helps in transferring process.

shape Example

[java] <target name="deploy" depends="war" unless="testsFailed"> <ftp server="${server.name}" remotedir="${remote.dir}" userid="${user.id}" password="${password}" passive="yes" binary="yes" verbose="yes"> <fileset dir="${build.dir}"> <include name="${war.name}"/> </fileset> </ftp> </target> [/java]

shape More Info

The entire process will be given in the status reports. Then, these reports should be moved further, which will be explained in next chapters.

Summary

shape Key Points

  • FTP server is used to deploy into QA machine.

shape Programming Tips

If dir attribute is not present, add mkdir task to prepare target to create mkdir.