[Since I'm not subscribed to nant-users and I expect the list to reject
my post, I keep all of you in CC]

On Fri, 3 Dec 2004, Gert Driesen <[EMAIL PROTECTED]> wrote:
> ----- Original Message ----- From: "Ian MacLean"
>> Gert Driesen wrote:
>> >>-----Original Message-----
>> >>From: Ian MacLean
>> >>Gert Driesen wrote:

>> >>>>>This is a legacy of Ant not having expressions or an if
>> >>>>>statement, so the only way to conditionally perform tasks was
>> >>>>>via this depends/if mechanism:

Yes and no.  I haven't been around when the if unless attribute on
target got introduced, I came a month or two to late (must have
happened somewhere in February/March 2000).

Part of the above is true.  It was introduced as a hack by Stefano
Mazzocci for his complex requirements in Cocoon and nobody really
thought long about it IIUC.  So it hasn't been a concious design
decision back then.

Many of the philosophical explanations for this and other things that
may look strange at first (why do if and unless only check for the
existance of the property and not its value?) have come as an
afterthought.  Of course Ant can't and won't change for backwards
compatibility reasons.  BWC has become the holy grail in Ant - and
rightly so, if you ask me.

We do have an FAQ on this
<http://ant.apache.org/faq.html#stop-dependency>, so at least it is
not intuitive enough to exist without any explanation.

BUT - in my experience it is the correct way to do it in the majority
of cases.

>> >>>I understand, but it does make sense that dependencies can have
>> >>>influence on whether or not the target should be executed.
>> >>
>> >>they can anyway :
>> >>
>> >><target name="foo" depends="foo-test" >
>> >> <if test="${foo-exists}" >
>> >>  <do-foo />
>> >> </if>
>> >></target>

You could do that in Ant as well - there is an <if> task in
Ant-Contrib that has been trivial to write (I did it 8-), but almost
nobody (including myself) ever uses it.

To a certain degree it is a declarative vs. procedural issue.

<target name="foo" if="foo-exists"> is more declarative, while the
example above is more procedural.  And Ant build files are supposed to
be declarative.  NAnt already has left this part of Ant's philosophy
behind.  I'm not judging, just observing.

>> >>however right now you *can't* stop a target *and* all its
>> >>dependencies from being run by using the if attribute - and that
>> >>seems like a big functionality hole.
>> >
>> >If your first use-case is that common, then how come it has taken
>> >several years for this to become an issue ? ;-)
>> >
>> fair point - I guess everyong has just worked around it up till
>> now.

Do you have a real world use-case for that?

I've never encountered that need, but frequently used if/unless the
way it is.  But my build needs may be different from yours.

Cheers

        Stefan

-- 
http://stefanbodewig.blogger.de/


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to