title: How to include Classpath Jars in a war file using Ant
body: <p>I am creating an ant script to build and deploy a project. My project structure is as follows:</p>
  
  <pre><code> Projectname
  --src
  --tst
  --lib ( I have 5 jars here)
  --resources
  --WebContent
        --META-INF
        --WEB-INF
              --lib (I have 3 jars here)
              --properties
              --templates
              --stylesheets
              --web.xml
  </code></pre>
  
  <p>My requirement is I have to write an ant script to build the project and create a war file in the staging environment (not local). The war should contain all the jar files available in the classpath ( classpath has more than 50 jars).
  But when I run my ant script it shows me only 8 jars, that are available in lib folders and does not include the jars from classpath.</p>
  
  <p>How to add classpath while creating a War file? Below is the script I have written for creating a war.</p>
  
  <pre><code>&lt;target name="war" description="Bundles the application as a WAR file" depends="build"&gt;
              &lt;echo&gt; === PACKAGE WAR ====== &lt;/echo&gt;
               &lt;delete dir="target" failonerror="false"/&gt;
               &lt;mkdir dir="target"/&gt;
              &lt;war destfile="target/test.war" needxmlfile="false" &gt;
                  &lt;fileset dir="WebRoot"&gt;
                      &lt;include name="**/*.*"/&gt;
                  &lt;/fileset&gt;
                  &lt;lib dir ="lib"&gt;
                      &lt;include name="**/*.*"/&gt;
                  &lt;/lib&gt;
  &lt;classes dir="WebContent/WEB-INF/classes"/&gt;
              &lt;/war&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>Classpath is as follows in the ant script. </p>
  
  <pre><code> &lt;property name="ExternalJars.location" value="../ExternalJars"/&gt;
   &lt;path id="Services.classpath"&gt;
  &lt;fileset dir="lib"&gt;
          &lt;include name="**/*.jar"/&gt;
      &lt;/fileset&gt;
  &lt;/path&gt;
  </code></pre>