title: How to include classpath jars into a jar in Ant
body: <p>I am developing a desktop application using swingx, spring and using ant to build them. This is my first project in ant. 
  How can add classpath jars to the executable jar build by ant? I have swingx, spring jar into my classpath. This my target for jar:</p>
  
  <pre><code>&lt;target name="jar"&gt;
      &lt;mkdir dir="build/jar" /&gt;
      &lt;jar destfile="build/jar/MainClass.jar" basedir="build/classes"&gt;
          &lt;manifest&gt;
              &lt;attribute name="Main-Class" value="MainClass" /&gt;
          &lt;/manifest&gt;         
      &lt;/jar&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>Edit:</p>
  
  <pre><code>&lt;project name="Number"&gt;
      &lt;description&gt;
              description
      &lt;/description&gt;
  
      &lt;property name="lib" value="lib" /&gt;
      &lt;property name="src" value="src" /&gt;
      &lt;property name="build" value="build" /&gt;
      &lt;property name="classes" value="classes" /&gt;
      &lt;property name="jar" value="jar"/&gt;
  
      &lt;target name="clean"&gt;
          &lt;delete dir="${build}" /&gt;
      &lt;/target&gt;
  
      &lt;path id="classpath"&gt;
          &lt;fileset dir="${lib}" includes="**/*.jar" /&gt;
      &lt;/path&gt;
  
      &lt;target name="compile"&gt;
          &lt;mkdir dir="${build}/${classes}" /&gt;
          &lt;javac srcdir="${src}" destdir="${build}/${classes}" classpathref="classpath" /&gt;
      &lt;/target&gt;
  
      &lt;target name="jar" depends="clean, compile"&gt;
          &lt;mkdir dir="${build}/${jar}" /&gt;
          &lt;jar destfile="build/jar/Number.jar" basedir="${build}/${classes}"&gt;
              &lt;manifest&gt;
                  &lt;attribute name="Main-Class" value="MainClass" /&gt;
              &lt;/manifest&gt;
              &lt;fileset file="test.txt"&gt;
              &lt;/fileset&gt;
          &lt;/jar&gt;
      &lt;/target&gt;
  
      &lt;target name="run"&gt;
          &lt;java jar="${build}/${jar}/MainClass.jar" fork="true" /&gt;
      &lt;/target&gt;
  &lt;/project&gt;
  </code></pre>