Title: RE: [nant-dev] Possible bug calling the same target more than once

That sounds like a great idea.  Actually I made a change similar to that earlier today and the everything worked fine... Except.....

It seems there is an issue with referencing properties inside the called target.  The first time you call a target and you reference an existing property, you get the value the property is set to.  If you then change the value of the property and recall the target, the called target has the original property value, not the newly changed value.

I didn't make the exact change you are (I didn't change the copy constructor, I removed the check for _hasExecuted from the Execute() method of the Target class), so hopefully your change will propagate the property changes correctly.

Below is the sample code I tested with earlier.  In this sample code, the value of the myProp property only returns a value of 2 when echoed immediately after the reassignment.

Thanks all...

Don



<project name="CallTester" default="startup">
<include buildfile="calltest2.build" verbose="true" />

        <target name="startup">
                <property name="myProp" value="1" />

                <echo message="Build project #1" />
                <call target="IncrementBuildNumber" />
                <call target="CompileProject" />

                <property name="myProp" value="2" />
                <echo message="${myProp}" />
                <echo message="Build project #2" />
                <call target="IncrementBuildNumber" />
                <call target="CompileProject" />
        </target>
       
        <target name="IncrementBuildNumber">
                <echo message="In IncrementBuildNumber" />
                <echo message="${myProp}" />
        </target>

        <target name="CompileProject">
                <echo message="In CompileProject" />
                <echo message="${myProp}" />
        </target>

</project>

-----Original Message-----
From: Scott Hernandez [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 2:06 PM
To: 'NAnt Developers'
Cc: 'Brad Wilson'
Subject: RE: [nant-dev] Possible bug calling the same target more than once


This is a good point and idea. It seems like a valid feature.

I don't think that we need to change the structure of the core all that much. I've written a copy constructor for Target that resets the _hasExecuted bit so each copy can be executed again.

        //Copy ctor
        public Target(Target t) {
            this._name = t._name;
            this._desc = t._desc;
            this._dependencies = t._dependencies;
            this._ifDefined = t._ifDefined;
            this._unlessDefined = t._unlessDefined;
            this._targetNode = t._targetNode;
            this._hasExecuted = false;
        }

With this in hand, a specific Task should be easy to write. This change is pretty small and should make it easy for people to extend, or execute arbitrary targets at will.

Sound good to all? (Unless I hear otherwise, I'll commit later today. :)

> -----Original Message-----
> From: [EMAIL PROTECTED]
[mailto:nant-developers-
> [EMAIL PROTECTED]] On Behalf Of Brad Wilson
> Sent: Friday, May 17, 2002 9:43 AM
> To: NAnt Developers
> Subject: Re: [nant-dev] Possible bug calling the same target more than
onc
> e
>
> Browning, Don wrote:
>
> > Does Ant have anything like a subroutine task?
>
> Not that I'm aware of. And you couldn't do it at the task level,
anyway.
> That's too late. It would have to be something added to the core of
NAnt
> as
> a parallel (but separate) thing like "target".
>
> Could it be done? Yes. Should it? I think so. What do others think?
>
> Brad


_______________________________________________________________

Hundreds of nodes, one monster rendering program.
Now that's a super model! Visit http://clustering.foundries.sf.net/
_______________________________________________
Nant-developers mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to