开发者

how to check the value of a property in Ant

开发者 https://www.devze.com 2023-04-11 19:46 出处:网络
I want to use Ant script to check if a property\'s value contains only开发者_开发百科 [a-Z] and [0-9]? If not then exit with an error.

I want to use Ant script to check if a property's value contains only开发者_开发百科 [a-Z] and [0-9]? If not then exit with an error.

Is it possible to do that in Ant?


You can check a property using the condition task, then use the fail task to exit. Here's a = slightly modified - example from the Ant manual. Use a matches condition. 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"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消