diff --git a/WHATSNEW b/WHATSNEW index 8375ecf8c..abf634bd4 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -156,6 +156,23 @@ Changes that could break older environments: adapt (by overriding the new two-arg processFile method). Bugzilla Report 23243. + * A new property syntax can be used to set attributes from + references: ${ant.ref:some-reference} + + In most cases this will yield the exact same result as + ${toString:some-reference} - only when an attribute setter method + accepts an object type other than string and the project's + reference is an Object of matching type the new syntax will pass in + that object. + + If your build file already contains properties whose name starts + with "ant.ref:" there is a potential for collision. If your + property has been set, normal property expansion will take + precedence over the new syntax. If the property has not been set + and a reference with the postfix of your property name exists + (i.e. in a very unlikely event) then the new syntax would yield a + different result (an expanded property) than Ant 1.7.1 did. + Fixed bugs: ----------- diff --git a/docs/manual/using.html b/docs/manual/using.html index c58832cc5..a8f87e785 100644 --- a/docs/manual/using.html +++ b/docs/manual/using.html @@ -804,6 +804,31 @@ For example, here is how to get a listing of the files in a fileset, There is no guarantee that external types provide meaningful information in such a situation
+Any Ant type which has been declared with a reference can also be
+ used as a property by using the ${ant.refid:}
+ operation, with the name of the reference listed after
+ the ant.refid:
text. The difference between this
+ operation and ${toString:}
is
+ that ${ant.refid:}
will expand to the referenced object
+ itself. In most circumstances the toString method will be invoked
+ anyway, for example if the ${ant.refid:}
is surrounded
+ by other text.
This syntax is most useful when using a task with attribute setters + that accept objects other than String. For example if the setter + accepts a Resource object as in
++public void setAttr(Resource r) { ... } ++
then the syntax can be used to pass in resource subclasses + preciously defined as references like
++ <url url="http://ant.apache.org/" id="anturl"/> + <my:task attr="${ant.refid:anturl}"/> +