开发者

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

开发者 https://www.devze.com 2023-01-17 10:00 出处:网络
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.

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


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>


Check out the ant pathconvert task. You can use this to expand an existing fileset into a list of files.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号