如何添加失败到ant macrodef
我创建了一个宏来搜索许多目录中的文件。那部分在起作用。
现在,如果找不到文件,我正在尝试将宏添加到宏中,但这给了我一个错误 macrodef不支持嵌套的“失败”元素。
有没有办法实现这一目标?
<macrodef name="searchfile">
<attribute name="file" />
<attribute name="path" default="${custom.buildconfig},${wst.basedir}" />
<attribute name="name" />
<attribute name="verbose" default="false" />
<sequential>
<first id="@{name}">
<multirootfileset basedirs="@{path}" includes="@{file}" erroronmissingdir="false" />
</first>
<property name="@{name}" value="${toString:@{name}}" />
<echo>property @{name} ${@{name}}</echo>
</sequential>
<fail message="${file}was not found in ${custom.buildconfig},${wst.basedir}">
<condition>
<equals arg1="${@{name}" arg2=""/>
</condition>
</fail>
</macrodef>
I created a macro to search for a file in a number of directories. That part is working.
Now I'm trying to add fail to the macro if no file is found but this gives me an errormacrodef doesn't support the nested "fail" element.
Is there a way to achieve this ?
<macrodef name="searchfile">
<attribute name="file" />
<attribute name="path" default="${custom.buildconfig},${wst.basedir}" />
<attribute name="name" />
<attribute name="verbose" default="false" />
<sequential>
<first id="@{name}">
<multirootfileset basedirs="@{path}" includes="@{file}" erroronmissingdir="false" />
</first>
<property name="@{name}" value="${toString:@{name}}" />
<echo>property @{name} ${@{name}}</echo>
</sequential>
<fail message="${file}was not found in ${custom.buildconfig},${wst.basedir}">
<condition>
<equals arg1="${@{name}" arg2=""/>
</condition>
</fail>
</macrodef>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
信用马丁·克莱顿(Martin Clayton)发表评论,在顺序解决该问题的情况下移动失败。
Credits to martin clayton for his comment, moving fail in the sequential fixes the issue.