Ant for script 如何在任何迭代失败时继续
Ant for script how to continue if any iteration fails
我正在编写一个 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>
结果:
它检查文件直到出现第一个错误,然后是 BUILD FAILED。
有人可以帮我吗?
for 任务不是标准 ANT 的一部分。这是此处记录的第 3 方扩展:
http://ant-contrib.sourceforge.net/tasks/tasks/for.html
文档建议使用 "keepgoing" 属性来忽略错误,这可能就是您正在寻找的答案。
如果这是您正在编写的自定义 ANT 任务,也许您应该考虑 refactoring the code to operate on a fileset?这将使您能够按如下方式调用任务:
<validate checkLanguages="true" checkKeysOrder="true">
<fileset dir="../web/WEB-INF" includes="*.txt" />
</validate>
更简单、更强大。
我正在编写一个 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>
结果: 它检查文件直到出现第一个错误,然后是 BUILD FAILED。
有人可以帮我吗?
for 任务不是标准 ANT 的一部分。这是此处记录的第 3 方扩展:
http://ant-contrib.sourceforge.net/tasks/tasks/for.html
文档建议使用 "keepgoing" 属性来忽略错误,这可能就是您正在寻找的答案。
如果这是您正在编写的自定义 ANT 任务,也许您应该考虑 refactoring the code to operate on a fileset?这将使您能够按如下方式调用任务:
<validate checkLanguages="true" checkKeysOrder="true">
<fileset dir="../web/WEB-INF" includes="*.txt" />
</validate>
更简单、更强大。