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开发者_开发百科 [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"/>
加载中,请稍侯......
精彩评论