ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: macrodef - do attributes as properties or substitutions
Date Fri, 14 Nov 2003 14:55:38 GMT
> > And the question was: how can I access the attribute-value?
> 
> @attribute or $(attribute) or - as long as we use a different notation
> we don't have to fear that we'd accidently clash with properties or
> scripting language constructs.

ok


> > If you write inside a target that would be value =
> > project.getProperty(name); But not here.
> 
> Neither is it in <scriptdef> for example.  If we say that the
> attribute doesn't turn into a property - and don't make it look like
> one - people won't expect they could get at it via
> project.getProperty.

agree


> > But the textual expansion has another disadvantage: 
> > if (parameter == "${name}") set-default-for-parameter;
> > You can´t do that ...
> 
> I'm afraid you've lost me.  

maybe - I haven´t followed thread not very intensive at the beginning ...


> What is the issue you are having here?

<macrodef name="macro">
    <attribute name="one"/>
    <attribute name="two" default="${one}"/>
</macrodef>
<macro one="hello"/>

Because the expansion isn´t done on that step, two is still set to "${one}".
So I had to check that inside my <script>
    one = "${one}";
    two = "${two}";          --> results in  two="${one}"
    if (two == "${one}") {   --> I can´t use that string for comparison
        two = one;
    }
The comparison won´t work because the static string is expanded to "hello",
but
I need "${one}" here. So you have to split that
    if (two == "${on" + "e}") {  --> that works
   


Jan

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message