Raghuveer wrote:
My customer requirement is to use ANT.
i.e
-       Application must use ANT to build and deploy

I have written build.xml for build.

What does "deploy" means.

"deployment" is the act of getting your program up and running on the server.

It could mean


1. to get your war file to the remote site and in the directory of the app server

use scp, ssh, copy,

  <!-- SCP logic from JDwA, core-chapter-08.xml -->


  <!--
    init file should look like
    ssh.server=192.168.2.84
    ssh.user=${user.name}
    ssh.dir=SmartFrog/dist/
    ssh.keyfile=${user.home}/.ssh/id_rsa
    ssh.passphrase=secret
    ssh.port=22
    ssh.verbose=true

the secure/ dir should not be readable by group; in windows lock it down
      -->
  <target name="ssh-init" depends="init">
    <fail unless="server">Set the "server" property!</fail>
    <property name="ssh.propfile"
        location="hosts/secure/${server}.ssh.properties"/>
    <loadproperties srcFile="${ssh.propfile}"/>
    <property name="tmp.dir" location="${build.dir}/tmp"/>
    <mkdir dir="${tmp.dir}"/>
    <presetdef name="ssh-cmd">
      <sshexec host="${ssh.server}"
          username="${ssh.user}"
          port="${ssh.port}"
          passphrase="${ssh.passphrase}"
          keyfile="${ssh.keyfile}"/>
    </presetdef>
    <presetdef name="ssh-cp">
      <scp
          passphrase="${ssh.passphrase}"
          keyfile="${ssh.keyfile}"
          port="${ssh.port}"
          verbose="${ssh.verbose}">
      </scp>
    </presetdef>
  </target>


  <target name="ssh-mkdirs" depends="ssh-init">
    <ssh-cmd command="mkdir -p ${ssh.dir}/bin"/>
    <ssh-cmd command="mkdir -p ${ssh.dir}/lib"/>
  </target>

  <target name="ssh-prepare-files" depends="install">
    <fileset id="ssh.fileset" dir="${install.dir}" includes="*.jar"/>
  </target>

  <!-- insert trust="true" to turn on trust -->
<target name="scp-upload" depends="ssh-init,ssh-mkdirs,ssh-stop,ssh-prepare-files">
    <echo>SCP target is ${ssh.server}</echo>
    <property name="ssh.path"
        value="[EMAIL PROTECTED]:${ssh.dir}"/>
    <!--copy the binaries-->
    <ssh-cp remoteToDir="${ssh.path}/lib">
      <fileset refid="ssh.fileset"/>
    </ssh-cp>
    <ssh-cp remoteToDir="${ssh.path}/bin">
      <fileset dir="hosts/${server}" includes="default.*"/>
    </ssh-cp>

  </target>

  <target name="ssh-stop" depends="ssh-init">
    <ssh-cmd command="cd ${ssh.dir}; nohup ./sfStopDaemon localhost &amp;"
    failonerror="false"/>
  </target>

  <target name="ssh-start" depends="ssh-init">
    <ssh-cmd command="cd ${ssh.dir}; nohup ./sfStartDaemon &amp;"/>
  </target>

  <target name="scp" depends="scp-upload,ssh-start"
      description="upload the files"/>


2.to configure the app server and the database correctly with the app running inside


  You can look at cargo from cargo.codehaus.org to do this

3. to scp up the the files then configure the app server and the database correctly with the app running inside on a remote box somewhere beyond your own firewall.

This is actually what happens in the example in (1), with the server-side workflow all handled by the smartfrog runtime:

http://www.hpl.hp.com/research/smartfrog/presentations/Taming_deployment_with_SmartFrog.pdf

This is not a trivial exercise, but, being automated, means I can roll out deployments to my home server from work, bring up the app server with the soap stack, have log4j route the output to a logs/ directory that one servlet context actually publishes, letting people remotely do it. Then we deploy a set of junit tests against that endpoint and three others on a different box and do real long haul testing of a SOAP endpoint.

How can be done the same using ANT.


It depends entirely what you want to do. I think the key goal of the (fairly minimal) requirements are that there is some target
        ant deploy
That will get your WAR or EAR file up to the server and into the right directory. If the app server (like jboss) has hot deployment of copied files, that is enough for a live redeploy. Though I prefer to use catcus as cold starts are cleaner.

However, as deployment varies with each project, there is no one <deploy> task that does your work.

I will leave you with one warning. Getting deployment right is hard. Start now, not a week before you go live.

-Steve








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to