Ant - 如何获取特定文件夹中所有文件的名称 [英] Ant - how to get all files' name in a specific folder

查看:39
本文介绍了Ant - 如何获取特定文件夹中所有文件的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我生成 jar 包的 Ant 脚本.我有一堆清单类路径属性的 jar 包,它们都在一个特定的文件夹中.

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>

谢谢

推荐答案

您在正确的轨道上,使用 manifestclasspath 任务.jarfile 属性用于创建指向文件集中包含的 jar 的相对链接.

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>

这篇关于Ant - 如何获取特定文件夹中所有文件的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆