【问题标题】:Convert shell script with list of files to ant build.xml将带有文件列表的 shell 脚本转换为 ant build.xml
【发布时间】:2013-01-31 18:07:23
【问题描述】:

我正在尝试将 linux shell 脚本的功能移植到 Windows ant build.xml。在 linux 脚本中,我被困在这一行,其中 $* 是文件列表 (*.txt):

java -classpath $myClasspath com.myProgram.Main /destinationDirectory $*

所以现在,在 ant 中,我传递了以空格分隔的文件名列表,但 ant java 任务认为这只是一个文件名,所以它会阻塞。有没有办法传入 *.txt 所以我不必在单独的嵌套元素中列出每个文件名?有任何想法吗?谢谢。

【问题讨论】:

    标签: linux windows shell ant


    【解决方案1】:

    这个问题很有帮助:

    使用它我能够创建这个 ant java 任务:

    <path id="myFiles">
      <fileset dir="src" includes="*.txt" />
    </path>
    
    <!-- convert fileset into a single property that is a space separated list of the file paths-->
    <pathconvert pathsep=" " property="myFilesPathConverted" refid="myFiles" />
    
    <java classname="com.myProgram.Main">
      <classpath refid="classpath"/>
      <arg value="${outputDirectory}" />
      <arg line="${myFilesPathConverted}" />
    </java> 
    

    【讨论】:

      猜你喜欢
      • 2016-04-28
      • 2015-08-27
      • 1970-01-01
      • 1970-01-01
      • 2012-12-31
      • 2014-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多