You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Bram Smeets <br...@smarthaven.com> on 2001/06/26 15:29:01 UTC

Project.setProperty(String,String)?

I have created a TokenizerTask that tokenizes a string and calls a certain
target for every token found.

My intention was to set a property that the tasks in the specified target
can reference by ${property}.
The problem is that when I set the property the first time, the task
executes by referencing the property.
The second time I set teh property, the task executes by referencing the old
value!

Any explanation?
Bram Smeets
SmartHaven


Re: Project.setProperty(String,String)?

Posted by Ken Wood <kw...@i2.com>.
Properties are immutable. You cannot change them.

Once you set them, they stay set, with
a few exceptions such as in <antcall>.

See the documentation.



Bram Smeets wrote:
> 
> I have created a TokenizerTask that tokenizes a string and calls a certain
> target for every token found.
> 
> My intention was to set a property that the tasks in the specified target
> can reference by ${property}.
> The problem is that when I set the property the first time, the task
> executes by referencing the property.
> The second time I set teh property, the task executes by referencing the old
> value!
> 
> Any explanation?
> Bram Smeets
> SmartHaven

Re: E-mail time delay?

Posted by Diane Holt <ho...@yahoo.com>.
--- Peter Donald <do...@apache.org> wrote:
> I am seeing it and I know of other people seeing it, however for most
> people  it seems to be a-ok. Not sure about the cause.

The mail I've sent today seems to be getting back out to the lists in the
usual (very fast) time, except one I sent this morning that has yet to
show up at all (to ant-user, in reply to a P4 question). It never came
back thru my mail, and it's not in the archive. Guess there's a bit-bucket
somewhere with it in it. Never seen that happen before.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: E-mail time delay?

Posted by Peter Donald <do...@apache.org>.
On Tue, 26 Jun 2001 23:43, Ken Wood wrote:
> I'm seeing a lot of variation between the time I
> see a message, and the origin of the message. It's
> often the case I see a reply to a message before
> the original message arrives.
>
> Is everyone seeing this, i.e. it's a list server issue,
> or am I the only one, i.e., it's a problem in house???

I am seeing it and I know of other people seeing it, however for most people 
it seems to be a-ok. Not sure about the cause.

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*

Re: E-mail time delay?

Posted by Ken Wood <kw...@i2.com>.
Just to illustrate, I sent this message at 8:43 AM June 26, and
it arrived in my inbox at 3:14 PM the same day... 

Ken Wood wrote:
> 
> I'm seeing a lot of variation between the time I
> see a message, and the origin of the message. It's
> often the case I see a reply to a message before
> the original message arrives.
> 
> Is everyone seeing this, i.e. it's a list server issue,
> or am I the only one, i.e., it's a problem in house???
> 
> -ken

E-mail time delay?

Posted by Ken Wood <kw...@i2.com>.
I'm seeing a lot of variation between the time I 
see a message, and the origin of the message. It's
often the case I see a reply to a message before
the original message arrives.

Is everyone seeing this, i.e. it's a list server issue,
or am I the only one, i.e., it's a problem in house???

-ken

Re: Project.setProperty(String,String)?

Posted by Stefan Bodewig <bo...@apache.org>.
Bram Smeets <br...@smarthaven.com> wrote:

> I did some further investigation and the property gets changed every
> token found.
> 
> So, how come the target which consists of:
> 
> <target name="testing">
>   <echo message="${engine}"/>
> </target>
> 
> still prints the former token??

Read the Life-cycle of a Task section in Developing with Ant in the
manual - especially item 10 (in the CVS version, that is).

The echo task will be configured using setMessage once, this is when
you run the target for the first time. Property expansion is
transparent to the task writer, which means the echo task doesn't see
${engine} but the value of the property at this time.

When you run the same target a second time, setMessage will not be
invoked again - this is not related to mutable or immutable properties
at all.

To work around this, you'll have to reconfigure all tasks in the
target you intend to run yourself.

Stefan

RE: Project.setProperty(String,String)?

Posted by Jose Alberto Fernandez <j_...@yahoo.com>.
Properties are not supposed to be used in that way.

Properties are considered inmutable. Most probably your task in the target
is prepared just once (the property expanded) and when you call the second
time the expansion has been cached ***because it is not supposed to
change***.

The only safe way to do what you want is for your task to be based on <ant*>
tasks which create a new context of execution where all properties are
reevaluated.

At least that is my take on your problem,

Jose Alberto

> -----Original Message-----
> From: Bram.Smeets@smarthaven.com [mailto:Bram.Smeets@smarthaven.com]On
> Behalf Of Bram Smeets
> Sent: Tuesday, June 26, 2001 2:51 PM
> To: ant-dev@jakarta.apache.org
> Subject: Re: Project.setProperty(String,String)?
>
>
> I did some further investigation and the property gets
> changed every token
> found.
>
> So, how come the target which consists of:
>
> <target name="testing">
>   <echo message="${engine}"/>
> </target>
>
> still prints the former token??
> I don't understand this behaviour.....
>
> Because I retrieve the Target and execute it twice (there are
> two tokens in
> my string).
> Is this causing this behaviour, should I clone it or is it
> just impossible??
>
> Thanks in advance,
> Bram
>
> ----- Original Message -----
> From: "Stefan Bodewig" <bo...@apache.org>
> To: <an...@jakarta.apache.org>
> Sent: Tuesday, June 26, 2001 3:43 PM
> Subject: Re: Project.setProperty(String,String)?
>
>
> > Bram Smeets <br...@smarthaven.com> wrote:
> >
> > > The problem is that when I set the property the first
> time, the task
> > > executes by referencing the property.  The second time I set teh
> > > property, the task executes by referencing the old value!
> >
> > The only explanation I have for this is that your property is a
> > user-property (which means it cannot be changed by
> > Project.setProperty).
> >
> > I've added a message when an override is ignored to
> > Project.setProperty in CVS.
> >
> > Stefan
> >
>


Re: Project.setProperty(String,String)?

Posted by Bram Smeets <br...@smarthaven.com>.
I did some further investigation and the property gets changed every token
found.

So, how come the target which consists of:

<target name="testing">
  <echo message="${engine}"/>
</target>

still prints the former token??
I don't understand this behaviour.....

Because I retrieve the Target and execute it twice (there are two tokens in
my string).
Is this causing this behaviour, should I clone it or is it just impossible??

Thanks in advance,
Bram

----- Original Message -----
From: "Stefan Bodewig" <bo...@apache.org>
To: <an...@jakarta.apache.org>
Sent: Tuesday, June 26, 2001 3:43 PM
Subject: Re: Project.setProperty(String,String)?


> Bram Smeets <br...@smarthaven.com> wrote:
>
> > The problem is that when I set the property the first time, the task
> > executes by referencing the property.  The second time I set teh
> > property, the task executes by referencing the old value!
>
> The only explanation I have for this is that your property is a
> user-property (which means it cannot be changed by
> Project.setProperty).
>
> I've added a message when an override is ignored to
> Project.setProperty in CVS.
>
> Stefan
>


Re: Project.setProperty(String,String)?

Posted by Stefan Bodewig <bo...@apache.org>.
Bram Smeets <br...@smarthaven.com> wrote:

> The problem is that when I set the property the first time, the task
> executes by referencing the property.  The second time I set teh
> property, the task executes by referencing the old value!

The only explanation I have for this is that your property is a
user-property (which means it cannot be changed by
Project.setProperty).

I've added a message when an override is ignored to
Project.setProperty in CVS.

Stefan