You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Erik Hatcher <ja...@ehatchersolutions.com> on 2002/08/22 11:43:30 UTC

Re: conditional copy

Yes, if you nest the task inside a conditional <target>.  Targets have 
conditional (if/unless) capability, but not tasks.

jfc wrote:
> Hi,
> 
> I have just been looking at the docs and it seems one can set a property 
> value conditionally.
> 
> Is there a way that I can have a task executed conditionally?
> 
> I'd like to say something like :
> 
> <condition>
>    <!-- predefined property -->
>    <property name="myprop" value="aaa">
>        <!-- so this copy will only happen if myprop == "aaa" -->
>        <copy   file="${project.home}/etc/Manifest.mf" 
> tofile="${build.home}/ear/war/META-INF/Manifest.mf"/>
>    </property>
> </condition>
> 
> Thanks
> jfc
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: conditional copy

Posted by Joey Gibson <jo...@joeygibson.com>.
On Thu, 22 Aug 2002 07:19:41 -0700 (PDT), Matt Benson
<gu...@yahoo.com> wrote:

||| I completely agree that the functionality is the same;
||| the <if> task only adds a minor convenience.

But what if I have a target that performs several functions, and only one
needs to be conditional? I then either have to define two different targets
and execute them based on a property, or split out my functionality into at
least one other target and then do an antcall. It would be much simpler to
have a bit of conditional logic in the one target to get the job done, IMO.

Joey

--
Oh great. My dog found the chainsaw...



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: conditional copy

Posted by Matt Benson <gu...@yahoo.com>.
I completely agree that the functionality is the same;
the <if> task only adds a minor convenience.

-Matt

--- Erik Hatcher <ja...@ehatchersolutions.com>
wrote:
> Its only fair to also add that the <if> task doesn't
> really add anything 
> to what can be done with conditional targets - an if
> and an unless 
> target could be used to handle both if/else types of
> conditions.
> 
> So you aren't really using a "conditional task",
> you're using a task 
> container that switches which sets of tasks it
> executes based on some 
> property.
> 
> 6 of one....
> 
> 	Erik
> 
> 
> Matt Benson wrote:
> > This is the normal way of doing things, and in
> fact,
> > conditionally executed tasks are what I use myself
> in
> > such a situation.  However, it is only fair to
> give
> > mention to ant-contrib's <if> task which provides
> > inline conditional task execution...
> > 
> > -Matt
> > 
> > --- jfc <jf...@btopenworld.com> wrote:
> > 
> >>jfc wrote:
> >>
> >>
> >>>Erik Hatcher wrote:
> >>>
> >>>
> >>>>Yes, if you nest the task inside a conditional
> >>>
> >><target>.  Targets 
> >>
> >>>>have conditional (if/unless) capability, but not
> >>>
> >>tasks.
> >>
> >>>>jfc wrote:
> >>>>
> >>>>
> >>>>>Hi,
> >>>>>
> >>>>>I have just been looking at the docs and it
> >>>>
> >>seems one can set a 
> >>
> >>>>>property value conditionally.
> >>>>>
> >>>>>Is there a way that I can have a task executed
> >>>>
> >>conditionally?
> >>
> >>>>>I'd like to say something like :
> >>>>>
> >>>>><condition>
> >>>>>   <!-- predefined property -->
> >>>>>   <property name="myprop" value="aaa">
> >>>>>       <!-- so this copy will only happen if
> >>>>
> >>myprop == "aaa" -->
> >>
> >>>>>       <copy  
> >>>>
> >>file="${project.home}/etc/Manifest.mf" 
> >>
> >
>
tofile="${build.home}/ear/war/META-INF/Manifest.mf"/>
> > 
> >>>>>   </property>
> >>>>></condition>
> >>>>>
> >>>>>Thanks
> >>>>>jfc
> >>>>>
> >>>>>
> >>>>>-- 
> >>>>>To unsubscribe, e-mail:   
>
>>>>><ma...@jakarta.apache.org>
> >>>>>For additional commands, e-mail: 
> >>>>><ma...@jakarta.apache.org>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>>-- 
> >>>>To unsubscribe, e-mail:   
> >>>><ma...@jakarta.apache.org>
> >>>>For additional commands, e-mail: 
> >>>><ma...@jakarta.apache.org>
> >>>>
> >>>>
> >>>thanks for that.
> >>>
> >>>its kinda 'call a target even if you're not going
> >>
> >>need to ignore its 
> >>
> >>>contents' but it works! ;-)
> >>>
> >>>jfc
> >>>
> >>>
> >>>
> >>>-- 
> >>>To unsubscribe, e-mail:   
> >>><ma...@jakarta.apache.org>
> >>>For additional commands, e-mail: 
> >>><ma...@jakarta.apache.org>
> >>>
> >>>
> >>sorry, that should be ' ... even if you're going
> to
> >>ignore its contents'
> >>
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:  
> >><ma...@jakarta.apache.org>
> >>For additional commands, e-mail:
> >><ma...@jakarta.apache.org>
> >>
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > HotJobs - Search Thousands of New Jobs
> > http://www.hotjobs.com
> > 
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> > 
> > 
> > 
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: conditional copy

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Its only fair to also add that the <if> task doesn't really add anything 
to what can be done with conditional targets - an if and an unless 
target could be used to handle both if/else types of conditions.

So you aren't really using a "conditional task", you're using a task 
container that switches which sets of tasks it executes based on some 
property.

6 of one....

	Erik


Matt Benson wrote:
> This is the normal way of doing things, and in fact,
> conditionally executed tasks are what I use myself in
> such a situation.  However, it is only fair to give
> mention to ant-contrib's <if> task which provides
> inline conditional task execution...
> 
> -Matt
> 
> --- jfc <jf...@btopenworld.com> wrote:
> 
>>jfc wrote:
>>
>>
>>>Erik Hatcher wrote:
>>>
>>>
>>>>Yes, if you nest the task inside a conditional
>>>
>><target>.  Targets 
>>
>>>>have conditional (if/unless) capability, but not
>>>
>>tasks.
>>
>>>>jfc wrote:
>>>>
>>>>
>>>>>Hi,
>>>>>
>>>>>I have just been looking at the docs and it
>>>>
>>seems one can set a 
>>
>>>>>property value conditionally.
>>>>>
>>>>>Is there a way that I can have a task executed
>>>>
>>conditionally?
>>
>>>>>I'd like to say something like :
>>>>>
>>>>><condition>
>>>>>   <!-- predefined property -->
>>>>>   <property name="myprop" value="aaa">
>>>>>       <!-- so this copy will only happen if
>>>>
>>myprop == "aaa" -->
>>
>>>>>       <copy  
>>>>
>>file="${project.home}/etc/Manifest.mf" 
>>
> tofile="${build.home}/ear/war/META-INF/Manifest.mf"/>
> 
>>>>>   </property>
>>>>></condition>
>>>>>
>>>>>Thanks
>>>>>jfc
>>>>>
>>>>>
>>>>>-- 
>>>>>To unsubscribe, e-mail:   
>>>>><ma...@jakarta.apache.org>
>>>>>For additional commands, e-mail: 
>>>>><ma...@jakarta.apache.org>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>-- 
>>>>To unsubscribe, e-mail:   
>>>><ma...@jakarta.apache.org>
>>>>For additional commands, e-mail: 
>>>><ma...@jakarta.apache.org>
>>>>
>>>>
>>>thanks for that.
>>>
>>>its kinda 'call a target even if you're not going
>>
>>need to ignore its 
>>
>>>contents' but it works! ;-)
>>>
>>>jfc
>>>
>>>
>>>
>>>-- 
>>>To unsubscribe, e-mail:   
>>><ma...@jakarta.apache.org>
>>>For additional commands, e-mail: 
>>><ma...@jakarta.apache.org>
>>>
>>>
>>sorry, that should be ' ... even if you're going to
>>ignore its contents'
>>
>>
>>
>>--
>>To unsubscribe, e-mail:  
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
> 
> 
> __________________________________________________
> Do You Yahoo!?
> HotJobs - Search Thousands of New Jobs
> http://www.hotjobs.com
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: conditional copy

Posted by Matt Benson <gu...@yahoo.com>.
This is the normal way of doing things, and in fact,
conditionally executed tasks are what I use myself in
such a situation.  However, it is only fair to give
mention to ant-contrib's <if> task which provides
inline conditional task execution...

-Matt

--- jfc <jf...@btopenworld.com> wrote:
> jfc wrote:
> 
> > Erik Hatcher wrote:
> >
> >> Yes, if you nest the task inside a conditional
> <target>.  Targets 
> >> have conditional (if/unless) capability, but not
> tasks.
> >>
> >> jfc wrote:
> >>
> >>> Hi,
> >>>
> >>> I have just been looking at the docs and it
> seems one can set a 
> >>> property value conditionally.
> >>>
> >>> Is there a way that I can have a task executed
> conditionally?
> >>>
> >>> I'd like to say something like :
> >>>
> >>> <condition>
> >>>    <!-- predefined property -->
> >>>    <property name="myprop" value="aaa">
> >>>        <!-- so this copy will only happen if
> myprop == "aaa" -->
> >>>        <copy  
> file="${project.home}/etc/Manifest.mf" 
> >>>
>
tofile="${build.home}/ear/war/META-INF/Manifest.mf"/>
> >>>    </property>
> >>> </condition>
> >>>
> >>> Thanks
> >>> jfc
> >>>
> >>>
> >>> -- 
> >>> To unsubscribe, e-mail:   
> >>> <ma...@jakarta.apache.org>
> >>> For additional commands, e-mail: 
> >>> <ma...@jakarta.apache.org>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >> -- 
> >> To unsubscribe, e-mail:   
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail: 
> >> <ma...@jakarta.apache.org>
> >>
> >>
> > thanks for that.
> >
> > its kinda 'call a target even if you're not going
> need to ignore its 
> > contents' but it works! ;-)
> >
> > jfc
> >
> >
> >
> > -- 
> > To unsubscribe, e-mail:   
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail: 
> > <ma...@jakarta.apache.org>
> >
> >
> sorry, that should be ' ... even if you're going to
> ignore its contents'
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: conditional copy

Posted by jfc <jf...@btopenworld.com>.
jfc wrote:

> Erik Hatcher wrote:
>
>> Yes, if you nest the task inside a conditional <target>.  Targets 
>> have conditional (if/unless) capability, but not tasks.
>>
>> jfc wrote:
>>
>>> Hi,
>>>
>>> I have just been looking at the docs and it seems one can set a 
>>> property value conditionally.
>>>
>>> Is there a way that I can have a task executed conditionally?
>>>
>>> I'd like to say something like :
>>>
>>> <condition>
>>>    <!-- predefined property -->
>>>    <property name="myprop" value="aaa">
>>>        <!-- so this copy will only happen if myprop == "aaa" -->
>>>        <copy   file="${project.home}/etc/Manifest.mf" 
>>> tofile="${build.home}/ear/war/META-INF/Manifest.mf"/>
>>>    </property>
>>> </condition>
>>>
>>> Thanks
>>> jfc
>>>
>>>
>>> -- 
>>> To unsubscribe, e-mail:   
>>> <ma...@jakarta.apache.org>
>>> For additional commands, e-mail: 
>>> <ma...@jakarta.apache.org>
>>>
>>>
>>>
>>
>>
>>
>> -- 
>> To unsubscribe, e-mail:   
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail: 
>> <ma...@jakarta.apache.org>
>>
>>
> thanks for that.
>
> its kinda 'call a target even if you're not going need to ignore its 
> contents' but it works! ;-)
>
> jfc
>
>
>
> -- 
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>
sorry, that should be ' ... even if you're going to ignore its contents'



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: conditional copy

Posted by jfc <jf...@btopenworld.com>.
Erik Hatcher wrote:

> Yes, if you nest the task inside a conditional <target>.  Targets have 
> conditional (if/unless) capability, but not tasks.
>
> jfc wrote:
>
>> Hi,
>>
>> I have just been looking at the docs and it seems one can set a 
>> property value conditionally.
>>
>> Is there a way that I can have a task executed conditionally?
>>
>> I'd like to say something like :
>>
>> <condition>
>>    <!-- predefined property -->
>>    <property name="myprop" value="aaa">
>>        <!-- so this copy will only happen if myprop == "aaa" -->
>>        <copy   file="${project.home}/etc/Manifest.mf" 
>> tofile="${build.home}/ear/war/META-INF/Manifest.mf"/>
>>    </property>
>> </condition>
>>
>> Thanks
>> jfc
>>
>>
>> -- 
>> To unsubscribe, e-mail:   
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail: 
>> <ma...@jakarta.apache.org>
>>
>>
>>
>
>
>
> -- 
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>
thanks for that.

its kinda 'call a target even if you're not going need to ignore its 
contents' but it works! ;-)

jfc



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>