You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Shawn Castrianni <Sh...@halliburton.com> on 2010/04/30 19:25:35 UTC

ANT 1.7.1 property evaluation

I am messing with IA2009 which comes with a custom ant task in their iaant.jar.  This custom ant task will execute an Install Anywhere build from ant.  The IA2008 ant task works fine, but they changed it for IA2009.  The new one seems to use nested ant task elements called <configuration>.  Within this nested ant task elements, are sub elements that use plain text arguments instead of xml attributes.  For example:

<configuration>
                <option1>value</option1>
                <option2>value</option2>
</configuration>

My problem is that if I specify an ant property for these values:

<option1>${option1Value}</option1>
<option2>${option2Value}</option2>

they are passed directly to the custom IA2009 ant task WITHOUT being evaluated by ANT first.  I have never needed to know the answer to this before, but:


Is it the custom ant task's responsibility to evaluate ant properties if passed to them OR does ANT evaluate these before passing it to the custom ant task?


I decompiled the ant task code and the class that handles the option sub elements just consumes the text as a plain String and does NOT assume it is an ant property that needs evaluating.  Is that a mistake on their part?

---
Shawn Castrianni

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

Re: ANT 1.7.1 property evaluation

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-04-30, Shawn Castrianni <Sh...@halliburton.com> wrote:

> I have never needed to know the answer to this before, but:

> Is it the custom ant task's responsibility to evaluate ant properties
> if passed to them OR does ANT evaluate these before passing it to the
> custom ant task?

Ant evaluates properties for attributes but it is the task's
responsibility to expand them for nested text of elements.  In you case
the values are given as nested text so the task must evaluate them
explicitly.

It would have been better if Ant had been handling attributes and nested
text the same way but unfortunately we got it wrong ten years ago and
now have to live with it in order to stay backwards compatible.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: ANT 1.7.1 property evaluation

Posted by David Weintraub <qa...@gmail.com>.
On Fri, Apr 30, 2010 at 1:25 PM, Shawn Castrianni> I am messing with
IA2009 which comes with a custom ant task in their iaant.jar.   The
[task] seems to use nested ant task elements called <configuration>.
Within this nested ant task elements, are sub elements that use plain
text arguments instead of xml attributes.  For example:
>
> <configuration>
>                <option1>value</option1>
>                <option2>value</option2>
> </configuration>
>
> My problem is that if I specify an ant property for these values:
> are passed directly to the custom IA2009 ant task WITHOUT being evaluated by ANT first.  I have never needed to know the answer to this before, but:

That is very strange. I would assume that the values would be
evaluated before being passed to the custom task. Yes, the values are
passed outside of a XML attribute, which is unusual in Ant, but not
unheard of. The <echo> task also allows you to surround what you want
with <echo></echo> and that allows the parameters to get passed
through.

Try executing Ant with the debug switch to see if this gives you any
more information what is going on.

You might be able to get around this by putting this custom task
inside a macro. That way, the macro fills in the valued.

<my-ai
   option1="${option1}"
   option2="${option2}"
/>

<macrodef name="myia">
    <attribute name="option1"/>
    <attribute name="option2"/>
    <sequencial>
        <ai-custom-task>
                <configuration>
                     <option1>@{option1}</option1>
                     <option2>@{option2}</option2>
                <configuration
        </ai-custom-task>
    </sequential>
</macrodef>

-- 
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org