You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Stefan Bodewig <bo...@bost.de> on 2000/11/07 12:43:54 UTC

Re: Property Checking In Build File

>>>>> "GR" == G Ramasubramani <gr...@aztec.soft.net> writes:

 GR>         If I do <target name="something" if="propertyname"> then
 GR> the target does not get executed but the user also does not get
 GR> to know about this.

Use <target name="cantDoSomething" unless="propertyname"> with a
<fail> task inside as well as 
<target name="phony" depends="something,cantDoSomething" />
and make "phony" your build target.

Stefan

Re: Property Checking In Build File

Posted by G Ramasubramani <gr...@aztec.soft.net>.
Thanks everybody! I get the idea. My brain had gone out to graze - hence the
question :-)

    So now I am searching the archives to see if there is a standard method to
execute a target only if a certain set of conditions are fulfilled - apart from
having one target per condition and providing the condition as the unless
parameter for the target. Does anybody want to give a hint ? ;-)

thanks a lot,
Rama

Peter Donald wrote:

> At 05:48  7/11/00 -0600, you wrote:
> >Why should this be complexity?  The srcdir parameter in the javac task
> >accepts a colon separated list of directories, the includes/excludes
> >supports a comma separated list and a few other parameters support this
> >concept of comma separated list.
> >
> >    Not having a comma separated list seems to be against the grain.
> >
> >    Something like
> >
> >        <target name="cantdosomething"
> >unless="property1,property2,property3">
> >
> >    would be immensely helpful and would not introduce any element of
> >complexity - at least in the usage :-)
>
> Well maybe not by itself. I can not remember the original object to this
> but it is probably the same as all the other objectsions. ie "The road to
> perl is paved with good intentions" ;)
>
> For instance if you did the above you would use "&&" operation in if and
> "||" in unless or as connector presumably. Eventually someone would want to
> add in "&&" operator to unless and perhaps scoping, then of course there
> would need to be negation and we may end up with
> unless="(a || b) && ( c || (!a || !b)) && !e)"
> in build files and that is pure hell to read ;) (Well not pure hell but it
> does make it more difficult and this would of course add complexity to
> other parts of system etc).
>
> Cheers,
>
> Pete
>
> *------------------------------------------------------*
> | "Nearly all men can stand adversity, but if you want |
> | to test a man's character, give him power."          |
> |       -Abraham Lincoln                               |
> *------------------------------------------------------*


Re: Property Checking In Build File

Posted by Peter Donald <do...@apache.org>.
At 05:48  7/11/00 -0600, you wrote:
>Why should this be complexity?  The srcdir parameter in the javac task
>accepts a colon separated list of directories, the includes/excludes
>supports a comma separated list and a few other parameters support this
>concept of comma separated list.
>
>    Not having a comma separated list seems to be against the grain.
>
>    Something like
>
>        <target name="cantdosomething"
>unless="property1,property2,property3">
>
>    would be immensely helpful and would not introduce any element of
>complexity - at least in the usage :-)

Well maybe not by itself. I can not remember the original object to this
but it is probably the same as all the other objectsions. ie "The road to
perl is paved with good intentions" ;)

For instance if you did the above you would use "&&" operation in if and
"||" in unless or as connector presumably. Eventually someone would want to
add in "&&" operator to unless and perhaps scoping, then of course there
would need to be negation and we may end up with
unless="(a || b) && ( c || (!a || !b)) && !e)" 
in build files and that is pure hell to read ;) (Well not pure hell but it
does make it more difficult and this would of course add complexity to
other parts of system etc).


Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*

Re: Property Checking In Build File

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "GR" == G Ramasubramani <gr...@aztec.soft.net> writes:

 GR> Why should this be complexity?

What would a comma separated list mean in the case of if? AND I
guess. And OR in the unless case? 

Oh, come on, just a little step to say  
if="property1 && (property2 || property3)". 

Well, wait, it is not that far away from saying 
if="property1 IN ('value1', 'value2')"

I think you see what I mean

Stefan

Re: Property Checking In Build File

Posted by G Ramasubramani <gr...@aztec.soft.net>.
Why should this be complexity?  The srcdir parameter in the javac task
accepts a colon separated list of directories, the includes/excludes
supports a comma separated list and a few other parameters support this
concept of comma separated list.

    Not having a comma separated list seems to be against the grain.

    Something like

        <target name="cantdosomething"
unless="property1,property2,property3">

    would be immensely helpful and would not introduce any element of
complexity - at least in the usage :-)

thanks,
Rama


Stefan Bodewig wrote:

> >>>>> "GR" == G Ramasubramani <gr...@aztec.soft.net> writes:
>
>  GR>         Could you tell me why the if/unless does not accept a
>  GR> comma separated list of properties?
>
> Complexity.
>
> One of Ant's ultimate design goals is simplicity and almost anything
> beyond the simple if/unless is bound to be ruled out as too much
> complexity. We developers have been called ultra-purists for this
> attitude already, feel free to chip in 8-).
>
> Stefan


Re: Property Checking In Build File

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "GR" == G Ramasubramani <gr...@aztec.soft.net> writes:

 GR>         Could you tell me why the if/unless does not accept a
 GR> comma separated list of properties?

Complexity.

One of Ant's ultimate design goals is simplicity and almost anything
beyond the simple if/unless is bound to be ruled out as too much
complexity. We developers have been called ultra-purists for this
attitude already, feel free to chip in 8-).

Stefan

Re: Property Checking In Build File

Posted by G Ramasubramani <gr...@aztec.soft.net>.
Hi Stefan,

        Thanks. That worked fine.

        Could you tell me why the if/unless does not accept a comma
separated list of properties?

thanks,
Rama


Stefan Bodewig wrote:

> >>>>> "GR" == G Ramasubramani <gr...@aztec.soft.net> writes:
>
>  GR>         If I do <target name="something" if="propertyname"> then
>  GR> the target does not get executed but the user also does not get
>  GR> to know about this.
>
> Use <target name="cantDoSomething" unless="propertyname"> with a
> <fail> task inside as well as
> <target name="phony" depends="something,cantDoSomething" />
> and make "phony" your build target.
>
> Stefan