You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by dave_davis <ni...@hotmail.com> on 2009/07/02 02:00:48 UTC

conditional logic and user input

Hi,

I want to be able to control my build depending on user input.  I've tried
the following code but the ifyes and ifno targets never run.  I'm new to ant
so am sure I've missed something fundamental but can't see what it is - all
help appreciated!

Cheers

Dave

<project name="test" default="myDefault">

	<target name="myDefault">
		<input message="Enter the value" addproperty="result" />
		<condition property="result.is.yes">
			<equals arg1="Y" arg2="${result}" />
		</condition>
		<condition property="result.is.no">
			<equals arg1="N" arg2="${result}" />
		</condition>
		<echo message="${result}"/>
		<echo message="${result.is.yes}"/>
		<echo message="${result.is.no}"/>
		<antcall target="ifyes" />
		<antcall target="ifno" />

	</target>

	<target name="ifyes" if="${result.is.yes}">
		<echo message="I am yes" />
	</target>
	<target name="ifno" if="${result.is.no}">
		<echo message="I am no" />
	</target>
</project>


-- 
View this message in context: http://www.nabble.com/conditional-logic-and-user-input-tp24298962p24298962.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


AW: conditional logic and user input

Posted by Ja...@rzf.fin-nrw.de.
You could also make the logic easier:
<target name="myDefault">
  <input addproperty="result" validargs="Y,N"  .../>
  <antcall target="do${result}"/>
</target>
<target name="doY"> ...
<target name="doN"> ...


Jan

>-----Ursprüngliche Nachricht-----
>Von: Rick Genter [mailto:rgenter@silverlink.com] 
>Gesendet: Donnerstag, 2. Juli 2009 17:09
>An: Ant Users List
>Cc: Rick Genter
>Betreff: RE: conditional logic and user input
>
>> From: dave_davis [mailto:nickcooke@hotmail.com]
>> Sent: Wednesday, July 01, 2009 5:01 PM
>> To: user@ant.apache.org
>> Subject: conditional logic and user input
>> 
>> 
>> Hi,
>> 
>> I want to be able to control my build depending on user input.  I've
>> tried
>> the following code but the ifyes and ifno targets never run.  I'm new
>> to ant
>> so am sure I've missed something fundamental but can't see what it is
>-
>> all
>> help appreciated!
>> 	<target name="ifyes" if="${result.is.yes}">
>> 		<echo message="I am yes" />
>> 	</target>
>> 	<target name="ifno" if="${result.is.no}">
>> 		<echo message="I am no" />
>> 	</target>
>
>The if attribute takes the name of the property, not its value. These
>should be
>
><target name="ifyes" if="result.is.yes">
>
>and
>
><target name="ifno" if="result.is.no">
>
>--
>Rick Genter
>Principal Software Engineer
>Silverlink Communications
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: conditional logic and user input

Posted by Rick Genter <rg...@silverlink.com>.
> From: dave_davis [mailto:nickcooke@hotmail.com]
> Sent: Wednesday, July 01, 2009 5:01 PM
> To: user@ant.apache.org
> Subject: conditional logic and user input
> 
> 
> Hi,
> 
> I want to be able to control my build depending on user input.  I've
> tried
> the following code but the ifyes and ifno targets never run.  I'm new
> to ant
> so am sure I've missed something fundamental but can't see what it is
-
> all
> help appreciated!
> 	<target name="ifyes" if="${result.is.yes}">
> 		<echo message="I am yes" />
> 	</target>
> 	<target name="ifno" if="${result.is.no}">
> 		<echo message="I am no" />
> 	</target>

The if attribute takes the name of the property, not its value. These
should be

<target name="ifyes" if="result.is.yes">

and

<target name="ifno" if="result.is.no">

--
Rick Genter
Principal Software Engineer
Silverlink Communications



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org