| “Strategies in (*)ability” | [iDareMedia] [JWare] [PET] [CI-Dashboard] |
The $message: value uri lets you display an entry from an installed AntX message resource bundle (<msgsbundle>) without first copying the parsed string into a project property or variable. You would use message uris for things like macrodef attribute values, feedback messages, and standard Ant tasks that do not support resource-bundle based strings. You must explicitly install this value uri’s handler; read the Examples section to see how this is done.
The general form of the uri is: $message:resource-id[?arg1[,,arg2]] where resource-id is the name of the resource message being read, and arg1 and arg2 are optional arguments to messages that are templates. Note that the arguments are separated by a double comma (,,). You can use the AntX value uri property reference syntax $(…) to refer to project properties from within the message uri itself or pipe the result of a property uri $property: directly into a message uri.
If you provide template arguments, the actual template positions they correspond to depend on the context in which the value uri is being used. Because positions {0} and {1} are reserved always for the current task’s name and file location, your arguments are normally passed as positions {2} and {3} to the message template string. However, when used as part of an <emit> task, your arguments are passed as positions {3} and {4} because <emit> includes a fixed timestamp parameter at position {2}.
1) The following snippet declares two scheme names for the message value uri handler: $message: and $string:. As a coding standard, you could use $message: for templated messages that expect arguments and $string: for non-template messages.
<manageuris action="install">
<parameter name="message"
value="com.idaremedia.antx.init.MessageValueURIHandler"/>
<parameter name="string"
value="com.idaremedia.antx.init.MessageValueURIHandler"/>
</manageuris>
2) The following snippet displays the contents of the greeting.msg string from the default or root message bundle. (If you have overlaid a message bundle using <overlay-msgs>, that bundle is searched before the root bundle.)
<echo message="${$string:greeting.msg}"/>
3) The following snippet does the same as 2), except this time the greeting.msg string is a template that requires two arguments. The script supplies two property values stored in ${starttime} and ${projectname}.
<echo message="${$message:greeting.msg?@(starttime),,@(projectname)}"/>
4) The following snippet declares a macrodef that uses messages uris to define some default attribute values.
<macrodef name="update-dashboard">
<attribute name="source" default="${$message:project.label}"/>
<attribute name="status" default="${$message:default.result?FAIL}"/>
…
</macrodef>