You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by don rhummy <do...@yahoo.com> on 2009/09/13 00:32:48 UTC

How add global property with input task?

When I have an Input task with "addProperty", the property it creates is only valid within that one target. So if two targets are being called in the same build run, the property added by the input task in target "1" is not visible in target "2"!! How would I add it globally?

The below two examples BOTH have the property "newProp" as existing only in target "one":

EXAMPLE ONE
------------
<target name="one">
     <input message="Enter something:" addProperty="newProp" />
</target


<target name="two">
     <!-- Should NOT be called -->
     <input message="Enter something:" addProperty="newProp" />
</target

//Command prompt call
mycomp> ant one two


EXAMPLE TWO
------------
<target name="one">
     <input message="Enter something:" addProperty="newProp" />
</target


<target name="two">
     <!-- Should NOT be called -->
     <input message="Enter something:" addProperty="newProp" />
</target

<target name="three">
     <antcall target="one" />
     <antcall target="two" />
</target

//Command prompt call
mycomp> ant three



      

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


Re: How add global property with input task?

Posted by don rhummy <do...@yahoo.com>.
I'm using ant 1.7.1 on Fedora 11 (installed Ant from the repositories instead of manually).

It does not work. Weird. i wonder if there's some mistake they made in the rpm?



--- On Sun, 9/13/09, Joe Schmetzer <jo...@exubero.com> wrote:

> From: Joe Schmetzer <jo...@exubero.com>
> Subject: Re: How add global property with input task?
> To: "Ant Users List" <us...@ant.apache.org>
> Date: Sunday, September 13, 2009, 3:48 AM
> 2009/9/12 don rhummy <do...@yahoo.com>:
> > When I have an Input task with "addProperty", the
> property it creates is only valid within that one target. So
> if two targets are being called in the same build run, the
> property added by the input task in target "1" is not
> visible in target "2"!! How would I add it globally?
> >
> > The below two examples BOTH have the property
> "newProp" as existing only in target "one":
> >
> > EXAMPLE ONE
> > ------------
> > <target name="one">
> >     <input message="Enter something:"
> addProperty="newProp" />
> > </target
> >
> >
> > <target name="two">
> >     <!-- Should NOT be called -->
> >     <input message="Enter something:"
> addProperty="newProp" />
> > </target
> >
> > //Command prompt call
> > mycomp> ant one two
> 
> This example works for me (that is, the "one" target sets
> the
> property, the "two" target does nothing. What version of
> ant are you
> using?
> 
> > EXAMPLE TWO
> > ------------
> > <target name="one">
> >     <input message="Enter something:"
> addProperty="newProp" />
> > </target
> >
> >
> > <target name="two">
> >     <!-- Should NOT be called -->
> >     <input message="Enter something:"
> addProperty="newProp" />
> > </target
> >
> > <target name="three">
> >     <antcall target="one" />
> >     <antcall target="two" />
> > </target
> >
> > //Command prompt call
> > mycomp> ant three
> 
> What you are trying to do here will not work. The
> <antcall> task
> actually sets up a completely new project, with its own
> properties.
> What you probably want to do here is use depends instead,
> i.e.
> 
> <target name="three" depends="one, two"/>
> 
> Regards,
> Joe
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 


      

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


Re: How add global property with input task?

Posted by Joe Schmetzer <jo...@exubero.com>.
2009/9/12 don rhummy <do...@yahoo.com>:
> When I have an Input task with "addProperty", the property it creates is only valid within that one target. So if two targets are being called in the same build run, the property added by the input task in target "1" is not visible in target "2"!! How would I add it globally?
>
> The below two examples BOTH have the property "newProp" as existing only in target "one":
>
> EXAMPLE ONE
> ------------
> <target name="one">
>     <input message="Enter something:" addProperty="newProp" />
> </target
>
>
> <target name="two">
>     <!-- Should NOT be called -->
>     <input message="Enter something:" addProperty="newProp" />
> </target
>
> //Command prompt call
> mycomp> ant one two

This example works for me (that is, the "one" target sets the
property, the "two" target does nothing. What version of ant are you
using?

> EXAMPLE TWO
> ------------
> <target name="one">
>     <input message="Enter something:" addProperty="newProp" />
> </target
>
>
> <target name="two">
>     <!-- Should NOT be called -->
>     <input message="Enter something:" addProperty="newProp" />
> </target
>
> <target name="three">
>     <antcall target="one" />
>     <antcall target="two" />
> </target
>
> //Command prompt call
> mycomp> ant three

What you are trying to do here will not work. The <antcall> task
actually sets up a completely new project, with its own properties.
What you probably want to do here is use depends instead, i.e.

<target name="three" depends="one, two"/>

Regards,
Joe

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


Re: How add global property with input task?

Posted by don rhummy <do...@yahoo.com>.
I figured out a workaround that's weird but it's the ONLY thing that makes the properties global and accessible outside the task where the input is used.

<target name="one">
     <input message="Enter val:" addProperty="newProp" />
     <property name="newProp" value="${newProp}" />
</target>

This actually works! It takes the value of the property "newProp" from the input and places it into a global property of the same name. Weird. I think the fact that input's "addProperty" doesn't make it global is a bug, since there's only supposed to be global properties in Ant.



--- On Sat, 9/12/09, don rhummy <do...@yahoo.com> wrote:

> From: don rhummy <do...@yahoo.com>
> Subject: How add global property with input task?
> To: user@ant.apache.org
> Date: Saturday, September 12, 2009, 6:32 PM
> When I have an Input task with
> "addProperty", the property it creates is only valid within
> that one target. So if two targets are being called in the
> same build run, the property added by the input task in
> target "1" is not visible in target "2"!! How would I add it
> globally?
> 
> The below two examples BOTH have the property "newProp" as
> existing only in target "one":
> 
> EXAMPLE ONE
> ------------
> <target name="one">
>      <input message="Enter
> something:" addProperty="newProp" />
> </target
> 
> 
> <target name="two">
>      <!-- Should NOT be called
> -->
>      <input message="Enter
> something:" addProperty="newProp" />
> </target
> 
> //Command prompt call
> mycomp> ant one two
> 
> 
> EXAMPLE TWO
> ------------
> <target name="one">
>      <input message="Enter
> something:" addProperty="newProp" />
> </target
> 
> 
> <target name="two">
>      <!-- Should NOT be called
> -->
>      <input message="Enter
> something:" addProperty="newProp" />
> </target
> 
> <target name="three">
>      <antcall target="one" />
>      <antcall target="two" />
> </target
> 
> //Command prompt call
> mycomp> ant three
> 
> 
> 
>       
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 


      

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