Summary: | Recursive property expansion | ||
---|---|---|---|
Product: | Ant | Reporter: | Jack J. Woehr <jwoehr> |
Component: | Core | Assignee: | Ant Notifications List <notifications> |
Status: | NEW --- | ||
Severity: | enhancement | CC: | mguillemot |
Priority: | P3 | Keywords: | PatchAvailable |
Version: | 1.7.0 | ||
Target Milestone: | 1.9.0 | ||
Hardware: | Sun | ||
OS: | Solaris | ||
Bug Depends on: | |||
Bug Blocks: | 52621 | ||
Attachments: |
A patch which along with a new file adds recursive property expansion ... messier patch file than the actual changes warrant since I reformatted the file in NetBeans.
This new file accompanies the PropertyHandler.java patch and goes in ..ant/util Test case to illustrate recursive property expansion Patch for file PropertyHelper.java that replaces my previous suggested patch and incorporates Wascally Wabbit's bug fix to the proposed patch |
Description
Jack J. Woehr
2004-06-02 18:44:22 UTC
Well, the whole reason for not having nested property expansion is that the parser does not do recursive nesting of brakets, which means that it cannot detect that you are in a nested situation. It it were able to detect the case, then I am almost certain we would allow nested expansion instead forbid it. Looking at your example, you have: ${${a}.${b}} the syntax for a property is: <prop> --> '${' <name>'}' and <name> --> [^}]* which means the above gets interpreted as: '${' "${a" '}' '.' '${' "b" '}' '}' - property "${a" does not exist so it is printed out textually - property "b" does exists, hence it is expanded If we change this to understand recursion, we may as well do nested expansions. I've done a sample enhancement to allow recursive property expansion. See attachments. Created attachment 11753 [details]
A patch which along with a new file adds recursive property expansion ... messier patch file than the actual changes warrant since I reformatted the file in NetBeans.
Created attachment 11754 [details]
This new file accompanies the PropertyHandler.java patch and goes in ..ant/util
Created attachment 11755 [details]
Test case to illustrate recursive property expansion
Changing title to reflect the recursive patch and making this an enhancement In a recent message (http://marc.theaimsgroup.com/?l=ant-user&m=108819303623796&w=2) to the users@ mailing list, Wascally Wabbit proposes a fix in my proposed patch to the file ant/PropertyHelper.java. His fix is added to my patch and the new patch for that one file is being attached to this report. Created attachment 11961 [details]
Patch for file PropertyHelper.java that replaces my previous suggested patch and incorporates Wascally Wabbit's bug fix to the proposed patch
I think that "Nested property expansion" would be a better title because ${foo} should evaluate to "red green ${blue}" if it is the value of the foo property no matter if a property "blue" exists or not. Why is this issue still opened and no committer has reacted since nearly 3 years? Because this is a useful feature, WebTest (probably the project that makes the most intensive usage of Ant) now performs nested properties evaluation during test execution. Partly because there is <scriptdef> that can do anything without even touching ANT core itself. I think this has been superseeded by 1.8.x's PropertyHelpers and the props Antlib - I'd even close this issue if the props Antlib had been released ... Hi Stefan ... Interesting to be discussing this 9.5 years later :) I will have to examine the props antlib ... thanks! Hi Jack, true, I must admit it felt a bit strange to me as well. |