https://issues.apache.org/bugzilla/show_bug.cgi?id=32638
--- Comment #7 from SlugFiller <[email protected]> 2009-07-12 16:14:39 PST --- The potential use of an "if" construct inside the macrodef could go beyond the capabilities of "sequencial". Taking the "nicer" example above, supposed you wanted the default classpath element to be no element at all, but wanted to keep the "nicer" syntax where it is used. You could use: <macrodef name="nicer"> ... <element name="classpath" optional="true" useContentOnly="false" /> <sequential> ... <java ...> <macroif ifTrue="classpath.element.set"> <classpath /> </macroif> </java> </sequential> </macrodef> That way you can use: <nicer /> <nicer> <classpath> <pathelement location="..." /> <path refid="classpath" /> </classpath> </nicer> Which expands to: <sequential> ... <java ... /> </sequential> <sequential> ... <java ...> <classpath> <pathelement location="..." /> <path refid="classpath" /> </classpath> </java> </sequential> Note the slight difference between the use of a modified "sequencial", and the use of "marcoif" - the latter effects the expanding phase and can contain any element, not just tasks. One aspect I am slightly worried about is name collision: If you make an additional macro element called classpath, you cannot enter an additional literal classpath element. The usual solution is to use different element names, but this doesn't work, and could become a common problem, if you want to use the useContentOnly feature. A possible solution is to add a special element namespace which is removed during expansion: <macrodef name="namespace"> ... <element name="include" namespace="element" useContentOnly="false" /> <sequential> ... <java ...> <element:include /> <include name="src/**/*.java" /> </java> </sequential> </macrodef> Then you can use: <namespace> <include name="plugins/**/*.java" /> </namespace> This would expand to: <sequential> ... <java ...> <include name="src/**/*.java" /> <include name="plugins/**/*.java" /> </java> </sequential> Note that the namespace is only used in the macrodef, not the macro instance nor the expansion, otherwise it wouldn't add anything to just using a different name. An alternative to a namespace would be to give an alias which is only used inside the macrodef: <macrodef name="namespace"> ... <element name="include" alias="moreinclude" useContentOnly="false" /> <sequential> ... <java ...> <moreinclude /> <include name="plugins/**/*.java" /> </java> </sequential> </macrodef> The usage and expansion are the same as above. An alternative, more self-explanatory name for the attribute could be "internally" or "internalName". One could take this one step further by having different element names during macro instance and post expansion, but that might be overkill. Not sure how useful all of this is, but it would certainly add some nice possibilities. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.
