2013-01-31 97 views
0

我試圖將linux shell腳本的功能移植到Windows Ant build.xml中。所以,現在將shell腳本與文件列表轉換爲ant build.xml

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

,螞蟻,我傳遞文件名的空格分隔列表:在Linux腳本,我卡在這條線,在$ *是文件列表(* .TXT) ,但螞蟻Java任務認爲這只是一個單一的文件名,所以它扼殺。有沒有辦法傳入* .txt,所以我不必在單獨的嵌套元素中列出每個文件名?有任何想法嗎?謝謝。

回答

1

這個問題是非常有益的:

使用它,我能創造這種螞蟻的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>