0
我正在編寫一個ant構建文件來檢查目錄中的所有翻譯文件。 我希望腳本的ant能夠在任何文件中出現檢查錯誤時繼續檢查其餘文件。 我的Ant任務: Ant腳本如果任何迭代失敗,如何繼續
<taskdef name="validate" classname="ValidateTranslateFile">
<classpath>
<pathelement location="${ant-libs-dir}/TranslateFileUtilities.jar" />
<pathelement location="../web/WEB-INF/lib/commons-io-2.5.jar" />
<pathelement location="../web/WEB-INF/lib/commons-lang3-3.5.jar" />
</classpath>
</taskdef>
<for param="program">
<path>
<fileset dir="../web/WEB-INF" includes="*.txt" />
</path>
<sequential>
<validate targetFile="@{program}" checkLanguages="true" checkKeysOrder="true" />
</sequential>
</for>
</target>
的結果: 它會檢查,直到第一個錯誤的文件出現,然後構建失敗。
任何人都可以幫助我嗎?
感謝您的解決方案。實際上我之前讀過那個頁面中的代碼,但我無法理解這種重構的方法論。 你知道如何迭代創建的文件嗎? –
@ AhmadAl-Khazraji我在這裏搜索了一些從開源項目中提取的示例:http://www.programcreek.com/java-api-examples/org.apache.tools.ant.types.FileSet。我個人更喜歡使用groovy腳本來擴展Ant,請參閱:http://stackoverflow.com/questions/5075017/ant-process-the-files-in-the-subfolder-using-tasks/5083342#5083342 –