Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Basic Deployment

Story

During the course of testing, the team is expending effort by manually copying the class files to a directory for deployment on the app server. Scott and Lisa decide to automate the process. They add a simple deploy target to the buildfile that will copy the required class files and JAR files to the correct directory. This will save time and effort because they are now having to deploy on a frequent basis.

A full deployment can be a complex process in which to fully automate the steps. The team is taking the correct approach in creating a simple process and adding the complexity only as needed. The deployment target described in Listing 3.26 will simply jar up the class files and copy the JAR file and all JSP pages to the deployment directory.

Listing 3.26 Simple Deployment Target

<?xml version="1.0" ?>
<project name="eMarket" default="compile" basedir=".">

  <taskdef name="requiredInput"
      classname="com.networksByteDesign.util.RequiredInput"/>

  <property name="dirs.source" value="/usr/projects/eMarket/src"    />
  <property name="dirs.backup" value="${user.home}/backup"       />
  <property name="dirs.temp"  value="/tmp"              />
  <property name="dirs.deploy" value="/usr/projects/appServer/eMarket" />

  <!-- compile target -->
  <target name="compile" description="Compile all of the source code.">
    <javac srcdir="${dirs.source}" />
  </target>

  <!-- deploy target -->
  <target name="deploy" description="Simple deployment of the app">
    <jar jarfile="${ant.project.name}.jar">
      <fileset dir="${dirs.source}" includes="**/*.class" />
    </jar>
    <copy file="${ant.project.name}.jar" todir="${dirs.deploy}" />
    <copy flatten="true" todir="${dirs.deploy}">
      <fileset dir="${dirs.source}" includes="**/*.jsp"/>
    </copy>
  </target>
</project>

Our <deploy> target begins by creating a JAR file containing all of the class files. The JAR file will be named with the name of the project, which in our case will create a JAR file called eMarket.jar. The file will be copied to the deployment directory.

The <deploy> target then goes on to copy all JSP pages to the deployment directory. Notice the flatten attribute in the <copy> task. When this attribute is set, the directory structure from the source is not preserved. So, even if the JSP pages are scattered in various subdirectories, they will be copied directly into the deployment directory.

Story

The group reached the end of the first iteration and their stories are complete. Also, because the buildfile is able to perform the needed requirements, Jeff and John decide to refactor it to clean it up. The development team and the customer get together and look over the user interface. As expected, the customer makes some changes in the user stories. At the iteration planning meeting for the second iteration, Sandy, Michael, the developers, and the customer meet again to have another look at the user stories. Once again, the customer sets the priorities based on business value, and the plan is created for the next iteration.

  • + Share This
  • 🔖 Save To Your Account