You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jason Rosenberg <ja...@squaretrade.com> on 2000/12/22 20:54:04 UTC

Need if/unless features

I would like to be able to have something similar to the if/unless
attributes for the <target> tag, which causes the if/unless gating
to happen before any of the dependent targets are evaluated.

There are cases where I do know that I don't want a target, or any
of its dependent targets to be evaluated, if a certain condition
is true.

I'm having some trouble coming up with good names for these attributes.
My favorites though:

if_a_priori
unless_a_priori

Also, in both cases, it would be very useful to have the ability to
have compound conditions, joined with 'and' or 'or', etc.

if_a_priori="TheSkyIsNotFalling" unless_a_priori="AlreadyDidAllThis" if="X or Y" unless="(A and B) or C"

Currently, what happens when you have an if and an unless in the
same target?  Is it allowed.  Are the 2 conditions "anded" or "ored"?

Jason

Re: Need if/unless features

Posted by James Duncan Davidson <du...@x180.net>.
On 1/6/01 9:11 PM, "Jason Rosenberg" <ja...@squaretrade.com> wrote:

>> <target name="main">
>>    <execute-target name="foo" if="property.foo"/>
>> </target>
>> 
>> <target name="foo" depends="bar, bap">..</target>
> 
> The <execute-target> task is good, probably the most succinct way to
> solve a lot of different requests/problems.  It should be augmented, however,
> with "else", "or", "and", "not" functionality.

Yeah. It seemed that way to me as well. Still seems that way. :) And yes,
you'd want to be able to do some combinatorial thing of all of those kinds
of functionality.


-- 
James Duncan Davidson                                        duncan@x180.net
                                                                  !try; do()


Re: Need if/unless features

Posted by Jason Rosenberg <ja...@squaretrade.com>.
----- Original Message ----- 
From: "James Duncan Davidson" <du...@x180.net>
To: <an...@jakarta.apache.org>
Sent: Tuesday, January 02, 2001 5:09 PM
Subject: Re: Need if/unless features


> On 12/29/00 4:36 AM, "Peter Donald" <do...@apache.org> wrote:
> 
> > Agreed - this is a problem ant2.0 will address hopefully. Many people have
> > asked for it in one way or another ... What I suggest is something like
> > 
> > <target name="t1" depends="t2"/>
> > <target name="t2" if="execute.t2"/>
> > 
> > <target name="t1" if="execute.t1">
> > <ant-call target="t1"/>
> > </target>
> > 
> > It is not efficient or pretty but it does work ;)
> 
> Um, do you really mean to define the same target twice? That doesn't flow
> very well.
> 
> The way that I think it should be solved is via a "execute-target" task.
> 
> <target name="main">
>    <execute-target name="foo" if="property.foo"/>
> </target>
> 
> <target name="foo" depends="bar, bap">..</target>
> 
> Having it as just a task means that nothing else gets done unless the
> property is set to 1 or true.
> 

The <execute-target> task is good, probably the most succinct way to
solve a lot of different requests/problems.  It should be augmented, however,
with "else", "or", "and", "not" functionality.

It would certainly be a benefit, though, above the current <antcall> task,
which has the shortcoming that it behaves as a new project, for which
any newly set properties that get set don't persist once the antcall task
is completed....

Jason


Re: Need if/unless features

Posted by James Duncan Davidson <du...@x180.net>.
On 12/29/00 4:36 AM, "Peter Donald" <do...@apache.org> wrote:

> Agreed - this is a problem ant2.0 will address hopefully. Many people have
> asked for it in one way or another ... What I suggest is something like
> 
> <target name="t1" depends="t2"/>
> <target name="t2" if="execute.t2"/>
> 
> <target name="t1" if="execute.t1">
> <ant-call target="t1"/>
> </target>
> 
> It is not efficient or pretty but it does work ;)

Um, do you really mean to define the same target twice? That doesn't flow
very well.

The way that I think it should be solved is via a "execute-target" task.

<target name="main">
   <execute-target name="foo" if="property.foo"/>
</target>

<target name="foo" depends="bar, bap">..</target>

Having it as just a task means that nothing else gets done unless the
property is set to 1 or true.

.duncan

-- 
James Duncan Davidson                                        duncan@x180.net
                                                                  !try; do()


Re: Need if/unless features

Posted by Peter Donald <do...@apache.org>.
At 02:54  22/12/00 -0500, Jason Rosenberg wrote:
>I would like to be able to have something similar to the if/unless
>attributes for the <target> tag, which causes the if/unless gating
>to happen before any of the dependent targets are evaluated.
  
>There are cases where I do know that I don't want a target, or any
>of its dependent targets to be evaluated, if a certain condition
>is true.
  
Agreed - this is a problem ant2.0 will address hopefully. Many people have
asked for it in one way or another ... What I suggest is something like

<target name="t1" depends="t2"/>
<target name="t2" if="execute.t2"/>

<target name="t1" if="execute.t1">
  <ant-call target="t1"/>
</target>

It is not efficient or pretty but it does work ;)
>Currently, what happens when you have an if and an unless in the
>same target?  Is it allowed.  Are the 2 conditions "anded" or "ored"?

don't know what the actual behaviour is but it should be undefined ;)
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: Need if/unless features

Posted by Peter Donald <do...@apache.org>.
At 02:54  22/12/00 -0500, Jason Rosenberg wrote:
>I would like to be able to have something similar to the if/unless
>attributes for the <target> tag, which causes the if/unless gating
>to happen before any of the dependent targets are evaluated.
  
>There are cases where I do know that I don't want a target, or any
>of its dependent targets to be evaluated, if a certain condition
>is true.
  
Agreed - this is a problem ant2.0 will address hopefully. Many people have
asked for it in one way or another ... What I suggest is something like

<target name="t1" depends="t2"/>
<target name="t2" if="execute.t2"/>

<target name="t1" if="execute.t1">
  <ant-call target="t1"/>
</target>

It is not efficient or pretty but it does work ;)
>Currently, what happens when you have an if and an unless in the
>same target?  Is it allowed.  Are the 2 conditions "anded" or "ored"?

don't know what the actual behaviour is but it should be undefined ;)
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               |
*-----------------------------------------------------*