Summary: | properties not expanded in default attributes | ||
---|---|---|---|
Product: | Ant | Reporter: | Vladimir Egorov <vladimir_egorov> |
Component: | Core tasks | Assignee: | Ant Notifications List <notifications> |
Status: | NEW --- | ||
Severity: | normal | CC: | melhaj |
Priority: | P2 | ||
Version: | 1.7.0 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP |
Description
Vladimir Egorov
2009-04-29 12:43:09 UTC
Suggested fix: add the following line value = getProject().replaceProperties(value); at line 343 org/apache/tools/ant/taskdefs/MacroInstance.java (the line number is from 1.6.5 source). The surrounding code looks like this: ... if (value == null) { throw new BuildException("required attribute " + attribute.getName() + " not set"); } value = getProject().replaceProperties(value); localProperties.put(attribute.getName(), value); copyKeys.remove(attribute.getName()); ... If I can get permission, I can make the change and add tests. --Vladimir properties do get resolved; <project> <property name="x" value="this is x"/> <macrodef name="run"> <attribute name="a" default="${x}"/> <sequential> <echo>a is @{a}</echo> </sequential> </macrodef> <run/> </project> i.e. they get resolve at the time of macro declaration, but not at the time of macro use. I am not sure that it is a good idea to resolve them again at run time. Thanks for your review. Yes, properties do get replaced at macro declaration time. This request is to also replace them at macro call time. Note that currently, the behavior is inconsistent: property in foo attribute got replaced, but not in bar. I would think that expression like ${${foo}} is most likely not what user had intended. Is there any reason to want this? This limitation keeps coming up in our framework. We like to use macrodef' feature of providing defaults for attributes in terms of previously defined attributes. But this breaks down, unexpectedly, when we try to use properties. Our users are telling us that we should fix this in the framework. |