title: How Apache Ant deploys .war file to Tomcat
body: <p>I'm using Apache Ant 1.8 to deploy a web application into a local Tomcat server, and the build.xml file (below) produces the desired effect when I run 'ant deploy' at the command line. </p>
  
  <p>My question is, I noticed that the .war file gets placed where I expect it to (deploy.dir is defined in my home directory's build.properties file), but it also unexpectedly unpacked the .war and extracted the context itself into that same directory. Where in the below build.xml file is that configured?</p>
  
  <p></p>
  
  <pre><code>  &lt;target name='init'&gt;
      &lt;property file='${user.home}/build.properties'/&gt;
      &lt;property name='app.name' value='${ant.project.name}'/&gt;
      &lt;property name='src.dir' location='src'/&gt;
      &lt;property name='lib.dir' location='lib'/&gt;
      &lt;property name='build.dir' location='build'/&gt;
      &lt;property name='classes.dir' location='${build.dir}/classes'/&gt;
      &lt;property name='dist.dir' location='${build.dir}/dist'/&gt;
    &lt;/target&gt;
  
    &lt;target name='initdirs' depends='init'&gt;
      &lt;mkdir dir='${classes.dir}'/&gt;
      &lt;mkdir dir='${dist.dir}'/&gt;
    &lt;/target&gt;
  
    &lt;target name='compile' depends='initdirs'&gt;
      &lt;javac srcdir='${src.dir}/java' destdir='${classes.dir}'&gt;
        &lt;!--
        &lt;classpath&gt;
          &lt;fileset dir='${lib.dir}/development' includes='javaee.jar'/&gt;
          &lt;fileset dir='${lib.dir}/production' includes='jr.jar'/&gt;
        &lt;/classpath&gt;
        --&gt;
      &lt;/javac&gt;
    &lt;/target&gt;
  
    &lt;target name='war' depends='compile'&gt;
      &lt;war destFile='${dist.dir}/${app.name}.war' webxml='${src.dir}/web/WEB-INF/web.xml'&gt;
        &lt;classes dir='${classes.dir}'/&gt;
        &lt;!--
        &lt;zipfileset dir='${lib.dir}/production' includes='jr.jar' prefix='WEB-INF/lib' /&gt;
        --&gt;
        &lt;fileset dir='${src.dir}/web' excludes='WEB-INF/web.xml' /&gt;
      &lt;/war&gt;
    &lt;/target&gt;
  
    &lt;target name='build' depends='war' description='compile and create the war' /&gt;
  
    &lt;target name='clean' depends='init' description='Use for a clean build'&gt;
      &lt;delete dir='${build.dir}' /&gt;
    &lt;/target&gt;
  
    &lt;target name='ffbuild' depends='clean, build' description='clean and create the war'/&gt;
  
    &lt;target name='deploy' depends='initdirs' description='copy the war file to the app server'&gt;
      &lt;delete verbose='true' dir='${deploy.dir}/${app.name}'/&gt;
      &lt;fail unless='deploy.dir' message='build.properties must exist in your home directory and define deploy.dir' /&gt;
      &lt;copy todir='${deploy.dir}' file='${dist.dir}/${app.name}.war'/&gt;
    &lt;/target&gt;
  </code></pre>
  
  <p></p>