Ant - how to get all files' name in a specific folder

Here is my Ant script for generating jar package. I have bunch of jar packages for manifest Class-Path attribute, they are all in an specific folder.

I don't want to hard code it, how can I get them automatically?

<jar jarfile="${client_deploy_dir}/HelloWorld.jar"
     basedir="${client_work_dir}/compiled">
   <manifest>
      <attribute name="Main-Class" value="HelloWorld.Main"/>
      <attribute name="Class-Path" value="???"/>
   </manifest>
</jar>

Thanks


Solution 1:

You're on the right track, use manifestclasspath task. The jarfile attribute is used to create relative links to the jars contained in the fileset.

<manifestclasspath property="jar.classpath" jarfile="${client_work_dir}/HelloWorld.jar">
  <classpath>
    <fileset name="" dir="${client_work_dir}/lib" includes="*.jar"/>
  </classpath>
</manifestclasspath>

<jar jarfile="${client_deploy_dir}/HelloWorld.jar" basedir="${client_work_dir}/compiled">
    <manifest>
         <attribute name="Main-Class" value="HelloWorld.Main"/>
         <attribute name="Class-Path" value=""${jar.classpath}"/>
      </manifest>
   </jar>