我正在尝试将 linux shell 脚本的功能移植到 Windows ant build.xml。在 linux 脚本中,我停留在这一行,其中 $* 是文件列表 (*.txt):
java -classpath $myClasspath com.myProgram.Main /destinationDirectory $*
所以现在,在 ant 中,我正在传递以空格分隔的文件名列表,但是 ant java 任务认为这只是一个文件名,所以它会阻塞。有没有办法传入 *.txt,这样我就不必在单独的嵌套元素中列出每个文件名?有任何想法吗?谢谢。
最佳答案
这个问题很有帮助:
使用它我能够创建这个 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>
关于linux - 将带有文件列表的 shell 脚本转换为 ant build.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14632301/