[英]how to check the value of a property in Ant
I want to use Ant script to check if a property's value contains only [aZ] and [0-9]? 我想使用Ant脚本检查属性值是否仅包含[aZ]和[0-9]? If not then exit with an error.
如果没有,则退出并返回错误。
Is it possible to do that in Ant? 是否可以在Ant中做到这一点?
You can check a property using the condition
task, then use the fail
task to exit. 您可以使用
condition
任务检查属性,然后使用fail
任务退出。 Here's a = slightly modified - example from the Ant manual . 这是Ant手册中的一个=稍作修改的示例。 Use a
matches
condition. 使用
matches
条件。 The regular expression will match any non-alpha, non-numeric character. 正则表达式将匹配任何非字母,非数字字符。
<condition property="nonalphanumeric">
<matches pattern="[^A-Z0-9]" string="${property.to.test}" casesensitive="false"/>
</condition>
<fail message="String contains non-alpha non-number" if="nonalphanumeric"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.