The following sections describe the custom evaluators provided by the Build Extensions Toolkit. Evaluators are extensions to the built-in Ant PropertyHelper task that perform specialized actions when resolving or creating Ant properties. Each Build Extensions Toolkit evaluator must be defined to Ant before it is used in an Ant script. If an evaluator is not used, it need not be defined. The following is an example script excerpt which is used to define the evaluators to Ant:
<xt:toArguments id="toArgumentsEvaluator"/>
<xt:toParameter id="toParameterEvaluator"/>
<xt:toStringArguments id="toStringArgumentsEvaluator"/>
<xt:toStringParameter id="toStringParameterEvaluator"/>
<xt:valueOf id="valueOfEvaluator"/>
<propertyhelper>
<delegate refid="toArgumentsEvaluator"/>
<delegate refid="toParameterEvaluator"/>
<delegate refid="toStringArgumentsEvaluator"/>
<delegate refid="toStringParameterEvaluator"/>
<delegate refid="valueOfEvaluator"/>
</propertyhelper>
First, the evaluator is given an ID, then the ID is used to define the evaluator as a PropertyHelper delegate.
The toArguments evaluator parses a parameter string, in the form "parameter(commaSeparatedArguments)", and returns the arguments for the parameter.
The toParameter evaluator parses a parameter string, in the form "parameter(commaSeparatedArguments)", and returns the parameter.
The toStringArguments evaluator resolves the specified property and parses the value as a parameter string, in the form "parameter(commaSeparatedArguments)", and returns the arguments for the parameter.
The toStringParameter evaluator resolves the specified property and parses the value as a parameter string, in the form "parameter(commaSeparatedArguments)", and returns the parameter.
The valueOf evaluator resolves the specified property and returns its value.
Examples:
<property name="project" value="endapar(a,b,c)"/>
<property name="argumentsString1" value="$${toArguments:${project}}"/>
<property name="parameterString1" value="$${toParameter:${project}}"/>
<property name="argumentsString2" value="$${toArguments: ${project} }"/>
<property name="parameterString2" value="$${toParameter: ${project} }"/>
<echo>toArguments: ${valueOf:argumentsString1}${line.separator}</echo>
<echo>toParameter: ${valueOf:parameterString1}${line.separator}</echo>
<echo>toArguments: ${valueOf:argumentsString2}${line.separator}</echo>
<echo>toParameter: ${valueOf:parameterString2}${line.separator}</echo>
<echo>toStringArguments: ${toStringArguments:project}${line.separator}</echo>
<echo>toStringParameter: ${toStringParameter:project}${line.separator}</echo>
<macrodef name="AntRestart">
<attribute name="project"/>
<attribute name="mac.project" default="${toParameter:@{project}}"/>
<attribute name="mac.targets" default="${toArguments:@{project}}"/>
<sequential>
<echo>mac.project: @{mac.project}${line.separator}</echo>
<echo>mac.targets: @{mac.targets}${line.separator}</echo>
</sequential>
</macrodef>
<AntRestart project="${project}"/>
Results:
toArguments: a,b,c
toParameter: endapar
toArguments: a,b,c
toParameter: endapar
toStringArguments: a,b,c
toStringParameter: endapar
mac.project: endapar
mac.targets: a,b,c