You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ja...@rzf.fin-nrw.de on 2003/12/10 08:45:03 UTC

RE: How to a act based on property value, _not_ if set [was: ANT copy on condition]

Or a nice trick:

<!-- which to use -->
<input addproperty="which" validargs="One,Two,Default"/>

<!-- that´s the trick -->
<antcall target="do${which}"/>

<target name="doOne"/>
<target name="doTwo"/>
<target name="doDefault"/>



Jan



> -----Original Message-----
> From: Daniel Blaukopf [mailto:blaukopf@netbeans.org]
> Sent: Wednesday, December 10, 2003 7:16 AM
> To: Ant Users List
> Subject: Re: How to a act based on property value, _not_ if set [was:
> ANT copy on condition]
> 
> 
> You can use the <condition> task with <equals> to make the 
> test beforehand:
> 
> --------
> 
> <antcall target="mytarget"/>
> 
> ...
> 
> <target name="checkLabelType">
>     <condition property="labelTypeIsNew">
>         <equals arg1="${label_type}" arg2="new"/>
>     </condition>
> </target>
> 
> <target name="mytarget" depends="checkLabelType" if="labelTypeIsNew">
> ...
> </target>
> 
> --------
> 
> Daniel
> 
> Avery Marvin R wrote:
> 
> >I've need to take an action based on the value of a property
> >(knowing that it's set does me no good). Jan's response to an
> >earlier question looks like a viable option, but is there an
> >easier way? For example if I have -
> >
> ><input validargs="new,existing" addproperty="label_type" 
> >message="Is this ear file based on a new or existing label?"/>
> >
> >I'd like to do, inside my ant script, as follows -
> >
> >if(label_type == "new"){
> > .....
> > }
> >else{
> > .....
> > }
> >
> >Thanks in advance.....
> >
> >MRA
> >
> >-----Original Message-----
> >From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> >Sent: Tuesday, December 09, 2003 5:03 AM
> >To: user@ant.apache.org
> >Subject: RE: ANT copy on condition
> >
> >
> >And you can do it inside a <script>
> >Something like
> >
> >    prop = project.getProperty("thePropertyName");
> >    if (prop != null) {
> >        copy = project.createTask("copy");
> >        copy.set....
> >        copy.perform();
> >    }
> >
> >
> >Jan
> >
> >  
> >
> >>-----Original Message-----
> >>From: Daniel Blaukopf [mailto:blaukopf@netbeans.org]
> >>Sent: Tuesday, December 09, 2003 11:02 AM
> >>To: Ant Users List
> >>Subject: Re: ANT copy on condition
> >>
> >>
> >>You can either put the copy operation in a separate target 
> >>(the Ant way) 
> >>or use the <if> task from ant-contrib.
> >>
> >><target name="copyFiles" if="myproperty">
> >>    <copy .../>
> >></target>
> >>
> >>Daniel
> >>
> >>Matthew Oatham wrote:
> >>
> >>    
> >>
> >>>Hi,
> >>>
> >>>I was wondering if it is possible to combine the condition 
> and copy 
> >>>tasks to only perfor the copoy task if a property is set?
> >>>
> >>>i.e.
> >>>if (property isset)  {
> >>> copy file
> >>>}
> >>>
> >>>Cheers.
> >>>
> >>>Matt
> >>>      
> >>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>